From bea5cb7e7e54fe2a291f360094f81d8beddb910f Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Sat, 3 Oct 2015 11:12:51 +0000 Subject: [PATCH] Fixes on deployment --- README.md | 3 +- orchestra/bin/orchestra-admin | 72 +++++++++++++++++++---------------- scripts/containers/deploy.sh | 18 ++++----- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index d3633506..cd672439 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,9 @@ pip3 install -r http://git.io/orchestra-requirements.txt orchestra-admin startproject panel python3 panel/manage.py migrate python3 panel/manage.py runserver -# Browse to http://127.0.0.1:8000/admin/ ``` -Now you can see the web interface on http://localhost:8000/admin +Now you can see the web interface on http://localhost:8000/admin/ Checkout the steps for other deployments: [development](INSTALLDEV.md), [production](INSTALL.md) diff --git a/orchestra/bin/orchestra-admin b/orchestra/bin/orchestra-admin index da9196fe..a303943d 100755 --- a/orchestra/bin/orchestra-admin +++ b/orchestra/bin/orchestra-admin @@ -60,6 +60,10 @@ check_root () { export -f check_root +verlt () { + [ "$1" = "$2" ] && return 1 || verlte $1 $2 +} + get_orchestra_dir () { if ! $(echo "import orchestra" | $PYTHON_BIN 2> /dev/null); then echo -e "\norchestra not installed.\n" >&2 @@ -109,6 +113,13 @@ function install_requirements () { check_root || true ORCHESTRA_PATH=$(get_orchestra_dir) || true + # Make sure locales are in place before installing postgres + if [[ $({ perl --help > /dev/null; } 2>&1|grep 'locale failed') ]]; then + run sed -i "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen + run locale-gen + update-locale LANG=en_US.UTF-8 + fi + # lxml: libxml2-dev, libxslt1-dev, zlib1g-dev APT="bind9utils \ ca-certificates \ @@ -123,44 +134,11 @@ function install_requirements () { wget \ xvfb \ zlib1g-dev" - - # cracklib and lxml are excluded on the requirements.txt because they need unconvinient system dependencies - PIP="$(wget http://git.io/orchestra-requirements.txt -O - | tr '\n' ' ') \ - cracklib \ - lxml==3.3.5" - if $testing; then APT="${APT} \ git \ iceweasel \ dnsutils" - - PIP="${PIP} \ - selenium \ - xvfbwrapper \ - freezegun \ - coverage \ - flake8 \ - django-debug-toolbar==1.3.0 \ - django-nose==1.4 \ - sqlparse \ - pyinotify \ - PyMySQL" - fi - - # Install a more recent version of wkhtmltopdf (0.12.2) (PDF page number support) - if [[ $(dpkg --list | grep wkhtmltox | awk {'print $3'}) != "0.12.2.1" ]]; then - wkhtmltox=$(mktemp) - wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb -O ${wkhtmltox} - dpkg -i ${wkhtmltox} || { echo "Installing missing dependencies for wkhtmltox..." && apt-get -f -y install; } - fi - - # Make sure locales are in place before installing postgres - if [[ $({ perl --help > /dev/null; } 2>&1|grep 'locale failed') ]]; then - run sed -i "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen - run locale-gen - update-locale LANG=en_US.UTF-8 - fi run apt-get update run apt-get install -y $APT @@ -174,7 +152,35 @@ function install_requirements () { update-ca-certificates fi + # cracklib and lxml are excluded on the requirements.txt because they need unconvinient system dependencies + PIP="$(wget http://git.io/orchestra-requirements.txt -O - | tr '\n' ' ') \ + cracklib \ + lxml==3.3.5" + if $testing; then + PIP="${PIP} \ + selenium \ + xvfbwrapper \ + freezegun \ + coverage \ + flake8 \ + django-debug-toolbar==1.3.0 \ + django-nose==1.4 \ + sqlparse \ + pyinotify \ + PyMySQL" + fi + run pip3 install $PIP + + # Install a more recent version of wkhtmltopdf (0.12.2) (PDF page number support) + wkhtmltox_version=$(dpkg --list | grep wkhtmltox | awk {'print $3'}) + if [[ ! $wkhtmltox_version || verlt $wkhtmltox_version 0.12.2.1 ]]; then + wkhtmltox=$(mktemp) + wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb -O ${wkhtmltox} + dpkg -i ${wkhtmltox} || { echo "Installing missing dependencies for wkhtmltox..." && apt-get -f -y install; } + fi + + } export -f install_requirements diff --git a/scripts/containers/deploy.sh b/scripts/containers/deploy.sh index b729763f..cadb1e1d 100644 --- a/scripts/containers/deploy.sh +++ b/scripts/containers/deploy.sh @@ -17,7 +17,7 @@ function test_orchestra () { echo echo ${bold} echo "> Checking if Orchestra is serving on https://${ip_addr}/admin/ ..." - if [[ $noinput == '--noinput' ]]; then + if [[ $noinput ]]; then echo " - username: $user" echo " - password: orchestra${normal}" fi @@ -90,7 +90,7 @@ function setup_database () { /etc/postgresql/${pg_version}/main/postgresql.conf fi run sudo service postgresql start - if [[ $noinput == '--noinput' ]]; then + if [[ $noinput ]]; then db_password=$(ps aux | sha256sum | base64 | head -c 10) run sudo python3 -W ignore manage.py setuppostgres --noinput --db_password $db_password else @@ -190,7 +190,7 @@ function main () { unset OPTIND unset opt - if [[ $noinput == '' ]]; then + if [[ ! $noinput ]]; then if [[ $(whoami) == 'root' ]]; then echo -e "\nErr. Interactive script should run as a regular user\n" >&2 exit 2 @@ -213,10 +213,10 @@ function main () { exit 5 fi - if [[ $noinput == '' && $bproject_name == false ]]; then + if [[ ! $noinput && $bproject_name == false ]]; then while true; do read -p "Enter a project name [panel]: " project_name - if [[ "$project_name" == "" ]]; then + if [[ ! "$project_name" ]]; then project_name="panel" break elif [[ ! $(echo "$project_name" | grep '^[_a-zA-Z]\w*$') ]]; then @@ -233,7 +233,7 @@ function main () { fi task=cronbeat - if [[ $noinput == '' ]]; then + if [[ ! $noinput ]]; then while true; do read -p "Do you want to use celery or cronbeat (orchestra.contrib.tasks) for task execution [cronbeat]? " task case $task in @@ -253,7 +253,7 @@ function main () { cd $project_name setup_database $dev "$noinput" - if [[ $noinput == '--noinput' ]]; then + if [[ $noinput ]]; then create_orchestra_superuser $user $user@localhost orchestra fi @@ -276,8 +276,8 @@ function main () { 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' + if [[ ! $ip_addr ]]; then + ip_addr=127.0.0.1 fi # Configure settings file into debug mode