2014-05-08 16:59:35 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-04-29 21:35:56 +00:00
|
|
|
set -ue
|
2015-04-29 13:17:21 +00:00
|
|
|
|
2015-09-30 20:33:25 +00:00
|
|
|
|
2015-10-01 18:02:23 +00:00
|
|
|
# bash <( curl https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/scripts/containers/deploy.sh )
|
|
|
|
|
2015-09-30 16:26:44 +00:00
|
|
|
function main () {
|
2015-09-30 18:24:45 +00:00
|
|
|
bold=$(tput -T ${TERM:-xterm} bold)
|
|
|
|
normal=$(tput -T ${TERM:-xterm} sgr0)
|
2015-09-30 16:26:44 +00:00
|
|
|
|
2015-09-30 18:24:45 +00:00
|
|
|
[ $(whoami) == 'root' ] && {
|
|
|
|
echo -e "\nErr. This script should run as a regular user\n" >&2
|
|
|
|
exit 1
|
2015-04-29 21:35:56 +00:00
|
|
|
}
|
2014-05-08 16:59:35 +00:00
|
|
|
|
2015-09-30 18:24:45 +00:00
|
|
|
run () {
|
|
|
|
echo " ${bold}\$ ${@}${normal}"
|
|
|
|
${@}
|
|
|
|
}
|
2014-05-08 16:59:35 +00:00
|
|
|
|
2015-09-30 18:24:45 +00:00
|
|
|
while true; do
|
2015-09-30 20:33:25 +00:00
|
|
|
read -p "Enter a project name [panel]: " project_name
|
|
|
|
if [[ "$project_name" == "" ]]; then
|
|
|
|
project_name="panel"
|
|
|
|
break
|
|
|
|
elif [[ ! $(echo "$project_name" | grep '^[_a-zA-Z]\w*$') ]]; then
|
|
|
|
if [[ ! $(echo "$project_name" | grep '^[_a-zA-Z]') ]]; then
|
|
|
|
message='make sure the name begins with a letter or underscore'
|
|
|
|
else
|
|
|
|
message='use only numbers, letters and underscores'
|
|
|
|
fi
|
|
|
|
echo "'$project_name' is not a valid %s name. Please $message."
|
2015-09-30 18:24:45 +00:00
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2015-09-30 20:33:25 +00:00
|
|
|
|
|
|
|
# TODO Password: Password (again):
|
2015-10-01 18:57:31 +00:00
|
|
|
# TODO detect if already installed and don't ask stupid question
|
|
|
|
# TODO setupceleryd shoudl change orchestra_start/stop/restart_services
|
|
|
|
# TODO setuppostgres should configure the fucking backend
|
2015-09-30 18:24:45 +00:00
|
|
|
read -p "Enter a new database password: " db_password
|
2015-09-30 20:33:25 +00:00
|
|
|
|
|
|
|
while true; do
|
2015-10-01 18:06:09 +00:00
|
|
|
read -p "Do you want to use celery or cronbeat for task execution [cronbeat]? " task
|
2015-09-30 20:33:25 +00:00
|
|
|
case $task in
|
|
|
|
'celery' ) task=celery; break;;
|
|
|
|
'cronbeat' ) task=cronbeat; break;;
|
|
|
|
'' ) task=cronbeat; break;;
|
|
|
|
* ) echo "Please answer celery or cronbeat.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
run sudo pip3 install django-orchestra==dev \
|
|
|
|
--allow-external django-orchestra \
|
|
|
|
--allow-unverified django-orchestra
|
|
|
|
run sudo orchestra-admin install_requirements
|
|
|
|
run cd $(eval echo ~$USER)
|
|
|
|
|
|
|
|
run orchestra-admin startproject $project_name
|
|
|
|
run cd $project_name
|
|
|
|
|
|
|
|
sudo service postgresql start
|
2015-10-01 18:57:31 +00:00
|
|
|
run sudo python3 -W ignore manage.py setuppostgres --db_password "$db_password"
|
2015-09-30 18:24:45 +00:00
|
|
|
|
2015-10-01 18:57:31 +00:00
|
|
|
run python3 -W ignore manage.py migrate
|
2015-09-30 18:24:45 +00:00
|
|
|
|
2015-09-30 20:33:25 +00:00
|
|
|
if [[ "$task" == "cronbeat" ]]; then
|
2015-10-01 18:57:31 +00:00
|
|
|
run python3 -W ignore manage.py setupcronbeat
|
|
|
|
run python3 -W ignore manage.py syncperiodictasks
|
2015-09-30 20:33:25 +00:00
|
|
|
else
|
2015-09-30 18:24:45 +00:00
|
|
|
run sudo apt-get install rabbitmq
|
2015-10-01 18:57:31 +00:00
|
|
|
run sudo python3 -W ignore manage.py setupcelery --username $USER
|
2015-09-30 20:33:25 +00:00
|
|
|
fi
|
2015-09-30 18:24:45 +00:00
|
|
|
|
2015-10-01 18:57:31 +00:00
|
|
|
run sudo python3 -W ignore manage.py setuplog --noinput
|
2015-09-30 18:24:45 +00:00
|
|
|
|
2015-10-01 18:57:31 +00:00
|
|
|
run python3 -W ignore manage.py collectstatic --noinput
|
2015-09-30 18:24:45 +00:00
|
|
|
run sudo apt-get install nginx-full uwsgi uwsgi-plugin-python3
|
2015-10-01 18:57:31 +00:00
|
|
|
run sudo python3 -W ignore manage.py setupnginx --user $USER
|
2015-10-01 20:14:32 +00:00
|
|
|
run sudo python3 -W ignore manage.py restartservices
|
2015-10-01 18:57:31 +00:00
|
|
|
run python3 -W ignore manage.py check --deploy
|
2015-09-30 16:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Wrap it all on a function to avoid partial executions when running through wget/curl
|
|
|
|
main
|