Fixes on deployment

This commit is contained in:
Marc Aymerich 2015-10-02 13:49:06 +00:00
parent 4dad82f527
commit 3a727baeda
1 changed files with 39 additions and 30 deletions

View File

@ -5,6 +5,44 @@ set -ue
# bash <( curl https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/scripts/containers/deploy.sh ) [--noinput username] # bash <( curl https://raw.githubusercontent.com/glic3rinu/django-orchestra/master/scripts/containers/deploy.sh ) [--noinput username]
bold=$(tput -T ${TERM:-xterm} bold)
normal=$(tput -T ${TERM:-xterm} sgr0)
function test_orchestra () {
user=$1
# Test if serving requests
ip_addr=$(ip addr show eth0 | grep 'inet ' | sed -r "s/.*inet ([^\s]*).*/\1/" | cut -d'/' -f1)
if [[ $ip_addr == '' ]]; then
ip_addr=127.0.0.1
fi
echo
echo ${bold}
echo "> Checking if Orchestra is serving on https://${ip_addr}/admin/ ..."
if [[ $noinput == '--noinput' ]]; then
echo -e " - username: $user"
echo -e " - password: orchestra${normal}"
fi
if [[ $(curl -s -L -k -c /tmp/cookies.txt -b /tmp/cookies.txt https://$ip_addr/admin/ | grep 'Panel Hosting Management') ]]; then
token=$(grep csrftoken /tmp/cookies.txt | awk {'print $7'})
if [[ $(curl -s -L -k -c /tmp/cookies.txt -b /tmp/cookies.txt \
-d "username=$user&password=orchestra&csrfmiddlewaretoken=$token" \
-e https://$ip_addr/admin/ \
https://$ip_addr/admin/login/?next=/admin/ | grep '<title>Panel Hosting Management</title>') ]]; then
echo "${bold} ** Orchestra appears to be working!${normal}"
else
echo "${bold} ** Err. Couldn't login :(${normal}" >&2
fi
else
echo "${bold} ** Err. Orchestra is not responding responding on https://${ip_addr}/admin/${normal}" >&2
fi
echo
}
function main () { function main () {
noinput='' noinput=''
user=$USER user=$USER
@ -42,9 +80,6 @@ function main () {
sudo true sudo true
fi fi
bold=$(tput -T ${TERM:-xterm} bold)
normal=$(tput -T ${TERM:-xterm} sgr0)
project_name="panel" project_name="panel"
if [[ $noinput == '' ]]; then if [[ $noinput == '' ]]; then
while true; do while true; do
@ -123,33 +158,7 @@ EOF
run sudo python3 -W ignore manage.py startservices run sudo python3 -W ignore manage.py startservices
surun "python3 -W ignore manage.py check --deploy" surun "python3 -W ignore manage.py check --deploy"
# Test if serving requests test_orchestra $user
ip_addr=$(ip addr show eth0 | grep 'inet ' | sed -r "s/.*inet ([^\s]*).*/\1/" | cut -d'/' -f1)
if [[ $ip_addr == '' ]]; then
ip_addr=127.0.0.1
fi
echo
echo ${bold}
echo "> Checking if Orchestra is serving on https://${ip_addr}/admin/ ..."
if [[ $noinput == '--noinput' ]]; then
echo -e " - username: $user"
echo -e " - password: orchestra${normal}"
fi
if [[ $(curl -L -k -c /tmp/cookies.txt -b /tmp/cookies.txt https://$ip_addr/admin/ | grep 'Panel Hosting Management') ]]; then
token=$(grep csrftoken /tmp/cookies.txt | awk {'print $7'})
if [[ $(curl -L -k -c /tmp/cookies.txt -b /tmp/cookies.txt \
-d "username=$user&password=orchestra&csrfmiddlewaretoken=$token" \
-e https://$ip_addr/admin/ \
https://$ip_addr/admin/login/?next=/admin/ | grep '<title>Panel Hosting Management</title>') ]]; then
echo "${bold} ** Orchestra appears to be working!${normal}"
else
echo "${bold} ** Err. Couldn't login :(${normal}" >&2
fi
else
echo "${bold} ** Err. Orchestra is not responding responding on https://${ip_addr}/admin/${normal}" >&2
fi
echo
} }
# 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