Added preliminar support for Docker containers
This commit is contained in:
parent
7af7c949b5
commit
34bad9613c
25
TODO.md
25
TODO.md
|
@ -390,3 +390,28 @@ Case
|
||||||
# saas custom domains support (maybe a new form field with custom url? autoconfigure websites?)
|
# saas custom domains support (maybe a new form field with custom url? autoconfigure websites?)
|
||||||
custom_url form field and validate/create/delete related website
|
custom_url form field and validate/create/delete related website
|
||||||
SAAS_PHPLIST_ALLOW_CUSTOM_URL = False
|
SAAS_PHPLIST_ALLOW_CUSTOM_URL = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CommandError:
|
||||||
|
run() encountered an error (return code 2) while executing 'su postgres -c "psql -c \"CREATE USER orchestra PASSWORD 'pane';\""'
|
||||||
|
b'could not change directory to "/home/orchestra/panel": Permission denied\npsql: could not connect to server: No such file or directory\n\tIs the server running locally and accepting\n\tconnections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?'
|
||||||
|
|
||||||
|
|
||||||
|
warning: no previously-included files matching '__pycache__' found under directory '*'
|
||||||
|
warning: no previously-included files matching '*~' found under directory '*'
|
||||||
|
warning: no previously-included files matching '*.save' found under directory '*'
|
||||||
|
changing mode of build/scripts-3.4/orchestra-beat from 644 to 755
|
||||||
|
changing mode of /usr/local/bin/orchestra-admin to 755
|
||||||
|
changing mode of /usr/local/bin/orchestra-beat to 755
|
||||||
|
File "/usr/local/lib/python3.4/dist-packages/orchestra/getips.py", line 15
|
||||||
|
print sliver['mgmt_net']['address']
|
||||||
|
^
|
||||||
|
SyntaxError: Missing parentheses in call to 'print'
|
||||||
|
|
||||||
|
File "/usr/local/lib/python3.4/dist-packages/orchestra/management/commands/setupnginx.py", line 234
|
||||||
|
"it? (yes/no): " % context)
|
||||||
|
^
|
||||||
|
SyntaxError: invalid syntax
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
#! /usr/bin/env python
|
|
||||||
|
|
||||||
import requests
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
SLICE_ID=1513
|
|
||||||
|
|
||||||
|
|
||||||
slice_req = requests.get('https://controller.community-lab.net/api/slices/%i' % SLICE_ID)
|
|
||||||
slice = json.loads(slice_req.content)
|
|
||||||
for sliver in slice['slivers']:
|
|
||||||
sliver_req = requests.get(sliver['uri'])
|
|
||||||
sliver = json.loads(sliver_req.content)
|
|
||||||
print sliver['mgmt_net']['address']
|
|
|
@ -231,7 +231,7 @@ class Command(BaseCommand):
|
||||||
# File is different, save the old one
|
# File is different, save the old one
|
||||||
if interactive:
|
if interactive:
|
||||||
if not confirm("\n\nFile %(file)s be updated, do you like to overide "
|
if not confirm("\n\nFile %(file)s be updated, do you like to overide "
|
||||||
"it? (yes/no): " % context)
|
"it? (yes/no): " % context):
|
||||||
return
|
return
|
||||||
run("cp %(file)s %(file)s.save" % context, display=True)
|
run("cp %(file)s %(file)s.save" % context, display=True)
|
||||||
run("cat << 'EOF' > %(file)s\n%(conf)s\nEOF" % context, display=True)
|
run("cat << 'EOF' > %(file)s\n%(conf)s\nEOF" % context, display=True)
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
FROM debian:latest
|
FROM debian:latest
|
||||||
|
|
||||||
RUN apt-get -y update && apt-get install -y git screen sudo python3 python3-pip wget curl dnsutils rsyslog nano ssh-client
|
RUN apt-get -y update && apt-get install -y git screen sudo python3 python3-pip wget curl dnsutils rsyslog nano ssh-client
|
||||||
RUN export TERM=xterm; curl https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/orchestra/bin/orchestra-admin | bash -s install_requirements
|
|
||||||
|
RUN curl https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/orchestra/bin/orchestra-admin | bash -s install_requirements
|
||||||
|
|
||||||
|
RUN apt-get -y install python3-psycopg2 postgresql nginx-full uwsgi uwsgi-plugin-python3
|
||||||
RUN apt-get clean
|
RUN apt-get clean
|
||||||
|
|
||||||
|
RUN useradd orchestra --password 'orchestra' && \
|
||||||
|
mkdir /home/orchestra && \
|
||||||
|
chmod 750 /home/orchestra && \
|
||||||
|
chown orchestra:orchestra /home/orchestra && \
|
||||||
|
adduser orchestra sudo
|
||||||
|
|
|
@ -1,151 +1,70 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Automated development deployment of django-orchestra
|
|
||||||
|
|
||||||
# This script is safe to run several times, for example in order to upgrade your deployment
|
|
||||||
|
|
||||||
set -ue
|
set -ue
|
||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
|
bold=$(tput -T ${TERM:-xterm} bold)
|
||||||
|
normal=$(tput -T ${TERM:-xterm} sgr0)
|
||||||
|
|
||||||
|
[ $(whoami) == 'root' ] && {
|
||||||
|
echo -e "\nErr. This script should run as a regular user\n" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
bold=$(tput -T ${TERM:-xterm} bold)
|
run () {
|
||||||
normal=$(tput -T ${TERM:-xterm} sgr0)
|
|
||||||
|
|
||||||
surun () {
|
|
||||||
echo " ${bold}\$ su $USER -c \"${@}\"${normal}"
|
|
||||||
su $USER -c "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
run () {
|
|
||||||
echo " ${bold}\$ ${@}${normal}"
|
echo " ${bold}\$ ${@}${normal}"
|
||||||
${@}
|
${@}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[ $(whoami) != 'root' ] && {
|
|
||||||
echo -e "\nErr. This script should run as root\n" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
USER='orchestra'
|
|
||||||
PASSWORD='orchestra'
|
|
||||||
HOME="/home/$USER"
|
|
||||||
PROJECT_NAME='panel'
|
|
||||||
BASE_DIR="$HOME/$PROJECT_NAME"
|
|
||||||
MANAGE="$BASE_DIR/manage.py"
|
|
||||||
PYTHON_BIN="python3"
|
|
||||||
CELERY=false
|
|
||||||
|
|
||||||
|
|
||||||
# Create a system user for running Orchestra
|
|
||||||
useradd $USER -s "/bin/bash" || true
|
|
||||||
echo "$USER:$PASSWORD" | chpasswd
|
|
||||||
mkdir -p $HOME
|
|
||||||
chown $USER.$USER $HOME
|
|
||||||
groups $USER | grep -E "(^|\s)$USER($|\s)" > /dev/null || run adduser $USER sudo
|
|
||||||
|
|
||||||
|
|
||||||
CURRENT_VERSION=$($PYTHON_BIN -c "from orchestra import get_version; print(get_version());" 2> /dev/null || false) || true
|
|
||||||
if [[ ! $CURRENT_VERSION ]]; then
|
|
||||||
# First Orchestra installation
|
|
||||||
run "apt-get -y install git python3-pip"
|
|
||||||
surun "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" || {
|
|
||||||
# Finishing partial installation
|
|
||||||
surun "export GIT_DIR=~/django-orchestra/.git; git pull"
|
|
||||||
}
|
}
|
||||||
PYTHON_PATH=$($PYTHON_BIN -c "import sys; print([path for path in sys.path if path.startswith('/usr/local/lib/python')][0]);")
|
|
||||||
echo $HOME/django-orchestra/ | sudo tee "$PYTHON_PATH/orchestra.pth"
|
|
||||||
fi
|
|
||||||
|
|
||||||
run "cp $HOME/django-orchestra/orchestra/bin/orchestra-admin /usr/local/bin/"
|
run sudo pip3 install django-orchestra==dev \
|
||||||
run "cp $HOME/django-orchestra/orchestra/bin/orchestra-beat /usr/local/bin/"
|
--allow-external django-orchestra \
|
||||||
|
--allow-unverified django-orchestra
|
||||||
|
run sudo orchestra-admin install_requirements
|
||||||
|
run cd $(eval echo ~$USER)
|
||||||
|
|
||||||
sudo orchestra-admin install_requirements --testing
|
while true; do
|
||||||
|
read -p "Enter a project name: " project_name
|
||||||
|
if [[ "$project_name" =~ ' ' ]]; then
|
||||||
|
echo "Spaces not allowed"
|
||||||
|
else
|
||||||
|
run orchestra-admin startproject $project_name
|
||||||
|
run cd $project_name
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [[ ! -e $BASE_DIR ]]; then
|
read -p "Enter a new database password: " db_password
|
||||||
cd $HOME
|
run sudo python3 manage.py setuppostgres --db_password "$db_password"
|
||||||
surun "orchestra-admin startproject $PROJECT_NAME"
|
|
||||||
cd -
|
|
||||||
else
|
|
||||||
echo "$BASE_DIR already existis, doing nothing."
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
run python3 manage.py migrate
|
||||||
|
run python3 panel/manage.py check --deploy
|
||||||
|
|
||||||
run "apt-get -y install postgresql"
|
function cronbeat () {
|
||||||
if [[ ! $(sudo su postgres -c "psql -lqt" | awk {'print $1'} | grep '^orchestra$') ]]; then
|
run python3 manage.py setupcronbeat
|
||||||
# orchestra database does not exists
|
run python3 panel/manage.py syncperiodictasks
|
||||||
# Speeding up tests, don't do this in production!
|
}
|
||||||
. /usr/share/postgresql-common/init.d-functions
|
|
||||||
POSTGRES_VERSION=$(psql --version | head -n1 | sed -r "s/^.*\s([0-9]+\.[0-9]+).*/\1/")
|
|
||||||
sed -i "s/^#fsync =\s*.*/fsync = off/" \
|
|
||||||
/etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf
|
|
||||||
sed -i "s/^#full_page_writes =\s*.*/full_page_writes = off/" \
|
|
||||||
/etc/postgresql/${POSTGRES_VERSION}/main/postgresql.conf
|
|
||||||
|
|
||||||
run "service postgresql restart"
|
function celery () {
|
||||||
run "$PYTHON_BIN $MANAGE setuppostgres --db_name orchestra --db_user orchestra --db_password orchestra"
|
run sudo apt-get install rabbitmq
|
||||||
# Create database permissions are needed for running tests
|
run sudo python3 manage.py setupcelery --username $USER
|
||||||
sudo su postgres -c 'psql -c "ALTER USER orchestra CREATEDB;"'
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
# create logfile
|
while true; do
|
||||||
surun "$PYTHON_BIN $MANAGE setuplog --noinput"
|
read -p "Do you want to use celery or cronbeat for task execution [cronbeat]?" task
|
||||||
|
case $task in
|
||||||
|
'celery' ) celery; break;;
|
||||||
|
'cronbeat' ) cronbeat; break;;
|
||||||
|
'' ) cronbeat; break;;
|
||||||
|
* ) echo "Please answer celery or cronbeat.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
run sudo python3 manage.py setuplog
|
||||||
|
|
||||||
# admin_tools needs accounts and does not have migrations
|
run python3 manage.py collectstatic --noinput
|
||||||
if [[ ! $(sudo su postgres -c "psql orchestra -q -c 'SELECT * FROM accounts_account LIMIT 1;' 2> /dev/null") ]]; then
|
run sudo apt-get install nginx-full uwsgi uwsgi-plugin-python3
|
||||||
surun "$PYTHON_BIN $MANAGE migrate --noinput"
|
run sudo python3 manage.py setupnginx --user $USER
|
||||||
else
|
run sudo python manage.py startservices
|
||||||
surun "$PYTHON_BIN $MANAGE postupgradeorchestra --from $CURRENT_VERSION"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [[ $CELERY == true ]]; then
|
|
||||||
run apt-get install -y rabbitmq
|
|
||||||
sudo $PYTHON_BIN $MANAGE setupcelery --username $USER --processes 2
|
|
||||||
else
|
|
||||||
surun "$PYTHON_BIN $MANAGE setupcronbeat"
|
|
||||||
surun "$PYTHON_BIN $MANAGE syncperiodictasks"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Install and configure Nginx+uwsgi web services
|
|
||||||
surun "mkdir -p $BASE_DIR/static"
|
|
||||||
surun "$PYTHON_BIN $MANAGE collectstatic --noinput"
|
|
||||||
run "apt-get install -y nginx uwsgi uwsgi-plugin-python3"
|
|
||||||
run "$PYTHON_BIN $MANAGE setupnginx --user $USER --noinput"
|
|
||||||
run "service nginx start"
|
|
||||||
|
|
||||||
# Apply changes on related services
|
|
||||||
run "$PYTHON_BIN $MANAGE restartservices" || true
|
|
||||||
|
|
||||||
# Create orchestra superuser
|
|
||||||
cat <<- EOF | $PYTHON_BIN $MANAGE shell
|
|
||||||
from orchestra.contrib.accounts.models import Account
|
|
||||||
if not Account.objects.filter(username="$USER").exists():
|
|
||||||
print('Creating orchestra superuser')
|
|
||||||
Account.objects.create_superuser("$USER", "$USER@localhost", "$PASSWORD")
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Change to development settings
|
|
||||||
PRODUCTION="from orchestra.conf.production_settings import \*"
|
|
||||||
DEVEL="from orchestra.conf.devel_settings import \*"
|
|
||||||
sed -i "s/^$PRODUCTION/# $PRODUCTION/" $BASE_DIR/$PROJECT_NAME/settings.py
|
|
||||||
sed -i "s/^#\s*$DEVEL/$DEVEL/" $BASE_DIR/$PROJECT_NAME/settings.py
|
|
||||||
|
|
||||||
|
|
||||||
cat << EOF
|
|
||||||
|
|
||||||
${bold}
|
|
||||||
* Admin interface login *
|
|
||||||
- username: $USER
|
|
||||||
- password: $PASSWORD
|
|
||||||
${normal}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wrap it all on a function to avoid partial executions when running through wget/curl
|
# Wrap it all on a function to avoid partial executions when running through wget/curl
|
||||||
|
|
Loading…
Reference in New Issue