From 3a727baeda9f5797a8d3bf51bb002ac3742bbddd Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Fri, 2 Oct 2015 13:49:06 +0000 Subject: [PATCH] Fixes on deployment --- scripts/containers/deploy.sh | 69 ++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/scripts/containers/deploy.sh b/scripts/containers/deploy.sh index 7bc57c76..af852089 100644 --- a/scripts/containers/deploy.sh +++ b/scripts/containers/deploy.sh @@ -5,6 +5,44 @@ set -ue # 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 'Panel Hosting Management') ]]; 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 () { noinput='' user=$USER @@ -42,9 +80,6 @@ function main () { sudo true fi - bold=$(tput -T ${TERM:-xterm} bold) - normal=$(tput -T ${TERM:-xterm} sgr0) - project_name="panel" if [[ $noinput == '' ]]; then while true; do @@ -123,33 +158,7 @@ EOF run sudo python3 -W ignore manage.py startservices surun "python3 -W ignore manage.py check --deploy" - # 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 -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 'Panel Hosting Management') ]]; 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 + test_orchestra $user } # Wrap it all on a function to avoid partial executions when running through wget/curl