diff options
Diffstat (limited to 'install')
| -rw-r--r-- | install/README | 9 | ||||
| -rw-r--r-- | install/README.md | 33 | ||||
| -rw-r--r-- | install/django.wsgi.template | 7 | ||||
| -rwxr-xr-x | install/install.sh | 271 | ||||
| -rwxr-xr-x | install/ishtar-delete-instance | 101 | ||||
| -rwxr-xr-x[-rw-r--r--] | install/ishtar-install (renamed from install/install-ishtar.sh) | 236 | ||||
| -rwxr-xr-x | install/ishtar-prepare-instance | 329 | ||||
| -rwxr-xr-x | install/ishtar-update | 103 | ||||
| -rw-r--r-- | install/local_settings.py.sample | 16 | ||||
| -rw-r--r-- | install/nginx.conf.template | 18 | ||||
| -rw-r--r-- | install/post_install_script.py | 28 | ||||
| -rwxr-xr-x | install/uninstall.sh | 36 | ||||
| -rw-r--r-- | install/uwsgi.ini.template | 2 | 
13 files changed, 759 insertions, 430 deletions
| diff --git a/install/README b/install/README deleted file mode 100644 index dc15fa147..000000000 --- a/install/README +++ /dev/null @@ -1,9 +0,0 @@ -cd /tmp -apt-get install wget -wget http://lysithea.proxience.net/ishtar-install.tar.gz - -tar xvzf ishtar-install.tar.gz -rm ishtar-install.tar.gz -cd install -export APP_NAME=myinstance && export URL=localhost \ -       && export PROJECT_NAME="Project name" && bash install.sh diff --git a/install/README.md b/install/README.md new file mode 100644 index 000000000..0235c2d6e --- /dev/null +++ b/install/README.md @@ -0,0 +1,33 @@ +Follow theses instruction to install Ishtar from sources on a Debian Jessie installation. + +### Get installations scripts + +``` +apt-get install wget +cd /usr/local/src +wget https://ishtar-archeo.net/install/install-ishtar.tar.bz2 + +tar xvzf ishtar-install.tar.gz +rm ishtar-install.tar.gz +``` + +#### Install Ishtar + +``` +cd /usr/local/src/install +bash ./ishtar-install +``` + +#### Configure an Ishtar instance + +``` +cd /usr/local/src/install +bash ./ishtar-prepare-instance +``` + +#### Delete an Ishtar instance + +``` +cd /usr/local/src/install +bash ./ishtar-delete-instance +``` diff --git a/install/django.wsgi.template b/install/django.wsgi.template deleted file mode 100644 index a618f0a41..000000000 --- a/install/django.wsgi.template +++ /dev/null @@ -1,7 +0,0 @@ -import os, sys -MAIN_PATH = os.path.realpath(os.path.dirname(__file__)) + "/.." -sys.path.append(MAIN_PATH) -os.environ['DJANGO_SETTINGS_MODULE'] = '#APP_NAME#.settings' -import django.core.handlers.wsgi -application = django.core.handlers.wsgi.WSGIHandler() - diff --git a/install/install.sh b/install/install.sh deleted file mode 100755 index 7a9a55bd7..000000000 --- a/install/install.sh +++ /dev/null @@ -1,271 +0,0 @@ -#!/bin/bash - -###################################################################### -# Minimum configuration                                              # -###################################################################### - -# only lower alpha-numeric char and '_' and must start with a letter -[ -z "$APP_NAME" ] && ( echo 'APP_NAME empty. Default to: "default".' ; ); -APP_NAME=${APP_NAME-default} - -[ -z $URL ] && ( echo 'URL empty. Default to: "localhost".' ; URL=localhost ; ); -URL=${URL-localhost} - -[ -z "$PROJECT_NAME" ] && ( echo 'PROJECT_NAME empty. Default to: "'$APP_NAME'".' ; ); -PROJECT_NAME=${PROJECT_NAME-$APP_NAME} - -DEFAULT_DATA='fr' # available data: 'fr' - -###################################################################### -# Advanced configuration                                             # -###################################################################### - -# if the database is not local the database will be not automatically -# created -[ -z $DB_HOST ] && ( echo 'DB_HOST empty. Default to: "127.0.0.1".' ; ); -DB_HOST=${DB_HOST-127.0.0.1} - -# if not set automatically generated -DB_PASSWORD=${DB_PASSWORD-''} -DB_PORT='5432' -PG_VERSION=9.1 - -# ishtar git branch -[ -z "$VERSION" ] && ( echo 'VERSION empty. Default to: "stable".' ; ); -VERSION=${VERSION-stable} - -# change it for each instance on a same server -UWSGI_PORT=${UWSGI_PORT-8891} - -# webserver port - default "80" -NGINX_PORT=${NGINX_PORT-80} - -# don't forget the trailing slash -INSTALL_PREFIX=/srv/ - -# if a virtualenv is used put the full path of the python to use -PYTHON=python - -# proxy for pip -PIP_OPTIONS='' -[ -z "$http_proxy" ] || PIP_OPTIONS=' --proxy '$http_proxy; -[ -z "$HTTP_PROXY" ] || PIP_OPTIONS=' --proxy '$HTTP_PROXY; - -# default for debian -UWSGI_AVAILABLE_PATH='/etc/uwsgi/apps-available/' -UWSGI_ENABLE_PATH='/etc/uwsgi/apps-enabled/' -NGINX_AVAILABLE_PATH='/etc/nginx/sites-available/' -NGINX_ENABLE_PATH='/etc/nginx/sites-enabled/' - -# Don't edit below this line -###################################################################### - -echo "* installing dependencies" - -if [ $DB_HOST = "127.0.0.1" ]; then -    apt-get -q -y install postgresql postgresql-$PG_VERSION-postgis postgresql 2> /dev/null > /dev/null -fi - -apt-get -q -y install git apg python-pip 2> /dev/null > /dev/null - -apt-get -q -y install python python-django \ -      libjs-jquery libjs-jquery-ui python-pisa python-django-registration \ -      python-utidylib python-lxml python-imaging python-django-south \ -      python-psycopg2 python-gdal gettext python-bs4 python-tidylib \ -      python-unicodecsv \ -      python-django-extra-views python-memcache python-dbf 2> /dev/null > /dev/null - -apt-get -q -y install uwsgi uwsgi-plugin-python nginx memcached 2> /dev/null > /dev/null - -pip install$PIP_OPTIONS BeautifulSoup4==4.3.2 - -if [ -z "$DB_PASSWORD" ] -then - -DB_PASSWORD=`apg -a 0 -M ncl -n 6 -x 10 -m 10 |head -n 1` - -fi - -DB_NAME='ishtar'$APP_NAME -INSTALL_PATH=$INSTALL_PREFIX$DB_NAME -DATE=`date +%F` -CDIR=`pwd` -SECRET_KEY=`apg -a 0 -M ncl -n 6 -x 10 -m 40 |head -n 1` - -if [ $DB_HOST = '127.0.0.1' ] -then - -echo "* create database and user" -DB_PASSWORD=$DB_PASSWORD DB_NAME=$DB_NAME PROJECT_NAME=$PROJECT_NAME PG_VERSION=$PG_VERSION su postgres <<'EOF' -cd -if [ `psql -l | grep template_postgis | wc -l` -ne 1 ]; then -    echo "  * create template_postgis" -    createdb template_postgis -    psql -d template_postgis -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-1.5/postgis.sql 2> /dev/null > /dev/null -    psql -d template_postgis -f /usr/share/postgresql/$PG_VERSION/contrib/postgis-1.5/spatial_ref_sys.sql 2> /dev/null > /dev/null - -fi -if [ `psql -l | grep $DB_NAME | wc -l` -ne 1 ]; then -    echo "  * create "$DB_NAME -    createuser --echo --adduser --createdb --encrypted $DB_NAME 2> /dev/null > /dev/null -    psql --command "ALTER USER \""$DB_NAME"\" with password '"$DB_PASSWORD"';" 2> /dev/null > /dev/null -    createdb -T template_postgis --echo --owner $DB_NAME --encoding UNICODE $DB_NAME "$PROJECT_NAME" 2> /dev/null > /dev/null - -fi -EOF - -fi - - -echo '* get sources' - -mkdir $INSTALL_PATH -mkdir $INSTALL_PATH'/conf' -cd $INSTALL_PATH - -echo '  * ishtar' -git clone https://gitlab.com/iggdrasil/ishtar.git 2> /dev/null -# echo '  * oook!' -# git clone git://git.proxience.com/git/oook_replace.git 2> /dev/null -# ln -s $INSTALL_PATH'/oook_replace/oook_replace' $INSTALL_PATH'/ishtar/' - -cd ishtar -git fetch 2> /dev/null -git checkout $VERSION 2> /dev/null - -cd django-simple-history -python setup.py install -cd .. - -cp -ra example_project $APP_NAME 2> /dev/null > /dev/null - -rm $APP_NAME/settings.py -ln -s $INSTALL_PATH"/ishtar/example_project/settings.py" $INSTALL_PATH"/ishtar/"$APP_NAME"/" - -APP_DIR=$INSTALL_PATH'/ishtar/'$APP_NAME - -echo '* load parameters' -sed -s "s|#APP_NAME#|$APP_NAME|g;\ -        s|#INSTALL_PATH#|$INSTALL_PATH|g;\ -        s|#DATE#|$DATE|g;\ -        s|#PROJECT_NAME#|$PROJECT_NAME|g;\ -        s|#DB_HOST#|$DB_HOST|g;\ -        s|#DB_NAME#|$DB_NAME|g;\ -        s|#DB_PORT#|$DB_PORT|g;\ -        s|#APP_DIR#|$APP_DIR|g;\ -        s|#SECRET_KEY#|$SECRET_KEY|g;\ -        s|#DB_PASSWORD#|$DB_PASSWORD|g;\ -        s|#UWSGI_PORT#|$UWSGI_PORT|g;" $CDIR'/local_settings.py.sample' > \ -                                  $INSTALL_PATH'/conf/local_settings.py' - -ln -s $INSTALL_PATH'/conf/local_settings.py' $APP_DIR'/local_settings.py' - -# rights -mkdir -p "$APP_DIR/media/imported" -mkdir -p "$APP_DIR/media/upload" -chown -R root:www-data $APP_DIR'/media' -chmod -R g+w $APP_DIR'/media' - -# logs -mkdir -p /var/log/django/ -chown root:www-data '/var/log/django' -touch '/var/log/django/ishtar-'$APP_NAME'.log' -chown root:www-data '/var/log/django/ishtar-'$APP_NAME'.log' -chmod g+w '/var/log/django/ishtar-'$APP_NAME'.log' - -cd $APP_DIR -./manage.py collectstatic --noinput 2> /dev/null > /dev/null - -# load locale data - -cd $INSTALL_PATH'/ishtar/archaeological_context_records' -django-admin compilemessages -l fr 2> /dev/null -cd $INSTALL_PATH'/ishtar/archaeological_files' -django-admin compilemessages -l fr 2> /dev/null -cd $INSTALL_PATH'/ishtar/archaeological_finds' -django-admin compilemessages -l fr 2> /dev/null -cd $INSTALL_PATH'/ishtar/archaeological_operations' -django-admin compilemessages -l fr 2> /dev/null -cd $INSTALL_PATH'/ishtar/archaeological_warehouse' -django-admin compilemessages -l fr 2> /dev/null -cd $INSTALL_PATH'/ishtar/ishtar_common' -django-admin compilemessages -l fr 2> /dev/null - -echo "* sync database" - -cd $APP_DIR -python ./manage.py syncdb --noinput 2> /dev/null > /dev/null -python ./manage.py migrate ishtar_common 2> /dev/null > /dev/null -python ./manage.py migrate archaeological_files 0013 2> /dev/null > /dev/null -python ./manage.py migrate archaeological_operations 2> /dev/null > /dev/null -python ./manage.py migrate archaeological_files 2> /dev/null > /dev/null -python ./manage.py migrate 2> /dev/null > /dev/null - -echo "* load default data" -# data migrations have created some default data - return to a clean state -python ./manage.py flush --noinput 2> /dev/null - -python ./manage.py loaddata \ -    '../fixtures/initial_data-auth-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../ishtar_common/fixtures/initial_data-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../ishtar_common/fixtures/initial_towns-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../archaeological_operations/fixtures/initial_data-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../archaeological_files/fixtures/initial_data-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../archaeological_context_records/fixtures/initial_data-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../archaeological_finds/fixtures/initial_data-'$DEFAULT_DATA'.json' 2> /dev/null -python ./manage.py loaddata \ -    '../archaeological_warehouse/fixtures/initial_data-'$DEFAULT_DATA'.json' 2> /dev/null - -echo "* create superuser" -python ./manage.py createsuperuser - -# "de-flush" migrations -$PYTHON ./manage.py migrate --fake 2> /dev/null > /dev/null - -# add a default site -#echo '[{"pk":null, "model": "sites.site", "fields": {"domain": "'$URL'", "name": "'$PROJECT_NAME'"}}]' > \ -#    /tmp/site.json -#python ./manage.py loaddata /tmp/site.json -#rm /tmp/site.json - -echo '* uwsgi configuration' - -sed -s "s|#APP_NAME#|$APP_NAME|g;\ -        s|#DB_NAME#|$DB_NAME|g;\ -        s|#URL#|$URL|g;\ -        s|#UWSGI_PORT#|$UWSGI_PORT|g;" $CDIR'/uwsgi.ini.template' > \ -                                       $INSTALL_PATH'/conf/uwsgi.ini' - -sed -s "s#APP_NAME#/$APP_NAME/g;" $CDIR'/django.wsgi.template' > \ -                    $INSTALL_PATH'/conf/'$APP_NAME'.wsgi' - -ln -s $INSTALL_PATH'/conf/uwsgi.ini' \ -      $UWSGI_AVAILABLE_PATH$APP_NAME'.ini' -ln -s $UWSGI_AVAILABLE_PATH$APP_NAME'.ini' \ -      $UWSGI_ENABLE_PATH$APP_NAME'.ini' - -service uwsgi restart - -echo '* nginx configuration' - - -sed -s "s|#APP_NAME#|$APP_NAME|g;\ -        s|#UWSGI_PORT#|$UWSGI_PORT|g;\ -        s|#DB_NAME#|$DB_NAME|g;\ -        s|#DATE#|$DATE|g;\ -        s|#NGINX_PORT#|$NGINX_PORT|g;\ -        s|#URL#|$URL|g;" $CDIR'/nginx.conf.template' > \ -                                       $INSTALL_PATH'/conf/nginx.conf' -ln -s $INSTALL_PATH'/conf/nginx.conf' \ -      $NGINX_AVAILABLE_PATH$APP_NAME'.conf' -ln -s $NGINX_AVAILABLE_PATH$APP_NAME'.conf' \ -      $NGINX_ENABLE_PATH$APP_NAME'.conf' - -service nginx restart - diff --git a/install/ishtar-delete-instance b/install/ishtar-delete-instance new file mode 100755 index 000000000..0cd004de3 --- /dev/null +++ b/install/ishtar-delete-instance @@ -0,0 +1,101 @@ +#!/bin/bash + +set -e + +cecho() { +  local code="\033[" +  case "$1" in +    black  | bk) color="${code}0;30m";; +    red    |  r) color="${code}1;31m";; +    green  |  g) color="${code}1;32m";; +    yellow |  y) color="${code}1;33m";; +    blue   |  b) color="${code}1;34m";; +    purple |  p) color="${code}1;35m";; +    cyan   |  c) color="${code}1;36m";; +    gray   | gr) color="${code}0;37m";; +    *) local text="$1" +  esac +  [ -z "$text" ] && local text="$color$2${code}0m" +  echo -e "$text" +} + +do_delete_instance() { +    NGINX_AVAILABLE_PATH='/etc/nginx/sites-available' +    NGINX_ENABLE_PATH='/etc/nginx/sites-enabled' +    UWSGI_AVAILABLE_PATH='/etc/uwsgi/apps-available' +    UWSGI_ENABLE_PATH='/etc/uwsgi/apps-enabled' + +    if [ ! -z '$CONFIG_PATH' ]; then +        CONFIG_PATH="/etc/ishtar/" +    fi + +    if [ ! -f $CONFIG_PATH/config ]; then +        echo ""; +        cecho r ""$CONFIG_PATH" is not a valid config file." +        echo "Have you properly install Ishtar sources?" +        echo "Run ishtar-install before this script."; +        echo ""; +        exit 1; +    fi + +    source $CONFIG_PATH/config + +    INSTANCES_FILE=$CONFIG_PATH/instances +    if [ ! -f $INSTANCES_FILE ]; then +        echo ""; +        cecho r "No instance installed. Exiting." +        echo ""; +        exit 1; +    fi +    echo "" +    cecho g "*******************************************************************************" +    cecho g "++++++               Ishtar instance deletion script                     ++++++" +    cecho g "*******************************************************************************" +    echo "" +    cecho y "Available instances:" +    echo "" + +    cat $INSTANCES_FILE + +    to_delete='' +    echo "" +    while [ "$to_delete" == '' ] +    do +        read -p "* Which one would you like to delete? " choice +        GRP=`cat $INSTANCES_FILE | grep "^$choice$"` +        if [ "$GRP" != '' ]; then +            to_delete=$choice +        fi +    done +    echo "" +    cecho r "Are you really sure to delete configuration, database and media attached to the " +    cecho r "instance "$to_delete"?" +    echo "" +    read -p "* Type DELETE if you are sure: " choice +    if [ "$choice" != "DELETE" ]; then +        exit 1 +    fi + +    sed '/'$to_delete'/d' $INSTANCES_FILE > /tmp/new_instances +    mv /tmp/new_instances $INSTANCES_FILE + +    INSTANCE=$to_delete +    rm -rf $ISHTAR_PATH/$INSTANCE +    rm -f "$NGINX_AVAILABLE_PATH/ishtar-$INSTANCE.conf" +    rm -f "$NGINX_ENABLE_PATH/ishtar-$INSTANCE.conf" +    rm -f "$UWSGI_AVAILABLE_PATH/ishtar-$INSTANCE.ini" +    rm -f "$UWSGI_ENABLE_PATH/ishtar-$INSTANCE.ini" + +    DB_NAME="ishtar-$INSTANCE" +    export DB_NAME +    su postgres <<'EOF' +        dropdb "$DB_NAME" +        dropuser "$DB_NAME" +EOF + +    echo "" +    cecho g $to_delete" have been completly removed" +    echo "" +} + +do_delete_instance diff --git a/install/install-ishtar.sh b/install/ishtar-install index 4c5995ca0..a94ce34d7 100644..100755 --- a/install/install-ishtar.sh +++ b/install/ishtar-install @@ -1,7 +1,24 @@ -#!/bin/sh +#!/bin/bash  set -e +cecho() { +  local code="\033[" +  case "$1" in +    black  | bk) color="${code}0;30m";; +    red    |  r) color="${code}1;31m";; +    green  |  g) color="${code}1;32m";; +    yellow |  y) color="${code}1;33m";; +    blue   |  b) color="${code}1;34m";; +    purple |  p) color="${code}1;35m";; +    cyan   |  c) color="${code}1;36m";; +    gray   | gr) color="${code}0;37m";; +    *) local text="$1" +  esac +  [ -z "$text" ] && local text="$color$2${code}0m" +  echo -e "$text" +} +  command_exists() {      command -v "$@" > /dev/null 2>&1  } @@ -37,13 +54,11 @@ EOF  do_install() { -    cat >&2 <<-'EOF' - -******************************************************************************* -++++++                    Ishtar installation script                     ++++++ -******************************************************************************* - -EOF +    echo "" +    cecho g "*******************************************************************************" +    cecho g "++++++                      Ishtar installation script                   ++++++" +    cecho g "*******************************************************************************" +    echo ""      # check user      user="$(id -un 2>/dev/null || true)" @@ -55,10 +70,8 @@ EOF          elif command_exists su; then              sh_c='su -c'          else -            cat >&2 <<-'EOF' -  Error: this installer needs the ability to run commands as root. -  We are unable to find either "sudo" or "su" available to make this happen. -EOF +            cecho r "  Error: this installer needs the ability to run commands as root." +            cecho r "  We are unable to find either "sudo" or "su" available to make this happen."              exit 1          fi      fi @@ -66,6 +79,7 @@ EOF      # check distribution      lsb_dist=''      dist_version='' +    backports_activated=''      if command_exists lsb_release; then          lsb_dist="$(lsb_release -si)"      fi @@ -104,6 +118,14 @@ EOF          ;;          debian) +            MAINBACKS=`cat /etc/apt/sources.list | grep jessie-backports |grep -v "^#"` +            ALLBACKS='' +            if [ "$(ls -A /etc/apt/sources.list.d/)" ]; then +                ALLBACKS=`cat /etc/apt/sources.list.d/* | grep jessie-backports |grep -v "^#"` +            fi +            if [ "$ALLBACKS" != '' ] || [ "$MAINBACKS" != '' ]; then +                backports_activated='true'; +            fi              dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"              case "$dist_version" in                  8) @@ -144,12 +166,10 @@ EOF          ubuntu|debian)              ;;          *) -            cat >&2 <<-'EOF' - -  Sorry. Either your platform is not easily detectable or not supported by -  this installer. - -EOF +            echo "" +            cecho r " Sorry. Either your platform is not easily detectable or not supported by" +            cecho r " this installer." +            echo ""              exit 1      esac @@ -163,7 +183,8 @@ EOF  EOF      while [ "$default_db" == '' ]      do -        read -p '* Default PostgreSQL host? [localhost] ' choice +        cecho y '* Default PostgreSQL host? [localhost] ' +        read choice          if [ "$choice" == '' ]; then              default_db='127.0.0.1'          elif [ "$choice" == 'localhost' ]; then @@ -185,7 +206,8 @@ EOF      MSG=""      while [ "$webserver" == '' ]      do -        read -p '* Which webserver do you want to use? ([nginx]/none) ' choice +        cecho y '* Which webserver do you want to use? ([nginx]/none) ' +        read choice          case "$choice" in              nginx ) webserver="nginx";;              none ) webserver="none";; @@ -197,26 +219,28 @@ EOF      cat >&2 <<-'EOF'  ------------------------------------------------------------------------------- -  Two version are usually available for Ishtar: master/stable. Master is the +  Two version are usually available for Ishtar: develop/master. Develop is the    bleeding edge version and you can experience problems with this version. -  Stable is the safest choice. +  Master is the safest choice.  EOF      while [ "$version" == '' ]      do -        read -p "* Which version would you like to use? ([stable]/master) " choice +        cecho y "* Which version would you like to use? ([develop]/master) " +        read choice          case "$choice" in -            stable ) version="stable";; +            develop ) version="develop";;              master ) version="master";; -            '' ) version="stable";; +            '' ) version="develop";;          esac      done -    etc_path="/etc/ishtar/"$version"/" +    etc_path="/etc/ishtar/"      if [ -d "$etc_path" ]; then          echo "" -        echo "ERROR: it seems that "$etc_path" already exists. If this is a remnant " -        echo "of an old installation please delete this path before installing." +        cecho r "ERROR: it seems that "$etc_path" already exists. If this is a remnant " +        cecho r "of an old installation please delete this path before installing." +        echo ""          exit 1      fi @@ -231,9 +255,10 @@ EOF  EOF      while [ "$install_path" == '' ]      do -        read -p "* Which base install path for Ishtar? [/srv/] " choice +        cecho y "* Which base install path for Ishtar? [/srv/]" +        read choice          if [ -z "$choice" ]; then -            install_path='/srv/' +            install_path='/srv'          elif [ ! -d "$choice" ]; then              echo 'Not a valid path.'          else @@ -241,106 +266,159 @@ EOF          fi      done -    full_install_path=$install_path'/ishtar/'$version +    full_install_path=$install_path'/ishtar/'      if [ -d "$full_install_path" ]; then          echo "" -        echo "ERROR: it seems that "$full_install_path" already exists. If this is a " -        echo "remnant of an old installation please delete this directory before installing." +        cecho r "ERROR: it seems that "$full_install_path" already exists. If this is a " +        cecho r "remnant of an old installation please delete this directory before installing." +        echo ""          exit 1      fi      echo "" -    echo "*******************************************************************************" +    cecho g "*******************************************************************************"      echo ""      # Run setup for each distro accordingly      case "$lsb_dist" in          ubuntu|debian) -            if [ "$dist_version" != "wheezy" ]; then -                cat >&2 <<-'EOF' - -  Sorry this script cannot manage your version of Debian/Ubuntu. - -EOF +            if [ "$dist_version" != "jessie" ] && [ "$dist_version" != "wheezy" ]; then +                echo "" +                cecho r " Sorry this script cannot manage your version of Debian/Ubuntu." +                echo ""                  exit 1              fi +            echo "-------------------------------------------------------------------------------"; +            cecho y "Update debian packages cache"; +            echo "";              export DEBIAN_FRONTEND=noninteractive              ( set -x; $sh_c 'sleep 3; apt-get update' ) -            if [ "$default_db" == 'localhost' ]; then -                POSTGIS=postgresql-9.1-postgis -                if [ "$dist_version" == "jessie" ]; then -                    POSTGIS=postgresql-9.4-postgis-2.1 -                fi -                ( set -x; $sh_c 'sleep 3; apt-get install -y -q postgresql '$POSTGIS ) -            fi              if ! command_exists git; then                  echo "-------------------------------------------------------------------------------"; -                echo "Installing git..."; +                cecho y "Installing git...";                  echo "";                  ( set -x; $sh_c 'sleep 3; apt-get install -y -q git' )              fi              if ! command_exists apg; then                  echo "-------------------------------------------------------------------------------"; -                echo "Installing apg..."; +                cecho y "Installing apg...";                  echo "";                  ( set -x; $sh_c 'sleep 3; apt-get install -y -q apg' )              fi              if ! command_exists pip; then                  echo "-------------------------------------------------------------------------------"; -                echo "Installing pip..."; +                cecho y "Installing pip...";                  echo "";                  ( set -x; $sh_c 'sleep 3; apt-get install -y -q python-pip' )              fi              if [ "$webserver" == 'nginx' ]; then                  echo "-------------------------------------------------------------------------------"; -                echo "Installing nginx and uwsgi..."; +                cecho y "Installing nginx and uwsgi...";                  echo "";                  ( set -x; $sh_c 'sleep 3; apt-get install -y -q  uwsgi uwsgi-plugin-python nginx' )              fi -            echo "-------------------------------------------------------------------------------"; -            echo "Installing Ishtar dependencies" -            echo ""; -            ( set -x; $sh_c 'sleep 3; apt-get install -y -q python python-django \ -      libjs-jquery libjs-jquery-ui python-pisa python-django-registration \ -      python-utidylib python-lxml python-imaging python-django-south \ -      python-psycopg2 python-gdal gettext python-unicodecsv memcached \ -      python-tidylib python-django-extra-views python-memcache python-dbf' ) -            ;; +            if [ "$dist_version" == "wheezy" ]; then +                if [ "$default_db" == '127.0.0.1' ]; then +                    echo "-------------------------------------------------------------------------------"; +                    cecho y "Installing postgresql" +                    echo "" +                    POSTGIS=postgresql-9.1-postgis +                    ( set -x; $sh_c 'sleep 3; apt-get install -y -q postgresql '$POSTGIS ) +                fi -    esac -    echo "-------------------------------------------------------------------------------"; -    echo "Installing BeautifulSoup4" -    echo ""; +                echo "-------------------------------------------------------------------------------"; +                cecho y "Installing Ishtar dependencies" +                echo ""; +                ( set -x; $sh_c 'sleep 3; apt-get install -y -q python python-django \ +          libjs-jquery libjs-jquery-ui python-pisa python-django-registration \ +          python-utidylib python-lxml python-imaging python-django-south \ +          python-psycopg2 python-gdal gettext python-unicodecsv memcached \ +          python-tidylib python-django-extra-views python-memcache python-dbf' ) -    ( set -x; $sh_c 'pip install BeautifulSoup4==4.3.2' ) -    echo "-------------------------------------------------------------------------------"; -    echo "Installing django-simple-history" -    echo ""; -    ( set -x; $sh_c 'pip install git+https://github.com/treyhunner/django-simple-history.git@0fd9b8e9c6f36b0141367b502420efe92d4e21ce' ) +                echo "-------------------------------------------------------------------------------"; +                cecho y "Installing BeautifulSoup4" +                echo ""; +                ( set -x; $sh_c 'pip install BeautifulSoup4==4.3.2' ) +                echo "-------------------------------------------------------------------------------"; +                cecho y "Installing django-simple-history" +                echo ""; +                ( set -x; $sh_c 'pip install git+https://github.com/treyhunner/django-simple-history.git@0fd9b8e9c6f36b0141367b502420efe92d4e21ce' ) + +            fi + +            if [ "$dist_version" == "jessie" ]; then +                if [ "$backports_activated" != 'true' ]; then +                    echo "" +                    cecho r "  In order to install Ishtar you have to activate Debian backports." +                    echo "  To do that:" +                    echo "" +                    echo "    echo 'deb http://ftp.debian.org/debian jessie-backports main contrib non-free' >> /etc/apt/sources.list" +                    echo "" +                    cecho p "  Run again Ishtar installation script after that." +                    exit 1 +                fi + +                if [ "$default_db" == '127.0.0.1' ]; then +                    echo "-------------------------------------------------------------------------------"; +                    cecho y "Installing postgresql" +                    echo "" +                    POSTGIS=postgresql-9.4-postgis-2.3 +                    ( set -x; $sh_c 'sleep 3; apt-get install -y -q postgresql '$POSTGIS ) +                fi +                echo "-------------------------------------------------------------------------------"; +                cecho y "Installing Ishtar dependencies" +                echo ""; +                ( set -x; $sh_c 'sleep 3; apt-get install -t jessie-backports -y -q python python-django\ +                      python-django-registration' ) +                ( set -x; $sh_c 'sleep 3; apt-get install -y -q \ +                      python-pisa python-bs4 python-django-formtools\ +                      python-tidylib python-lxml python-imaging python-html5lib\ +                      python-psycopg2 python-gdal gettext python-unicodecsv memcached \ +                      python-django-extra-views python-memcache python-dbf python-markdown' ) +                echo "-------------------------------------------------------------------------------"; +                cecho y "Installing django-simple-history" +                echo ""; +                ( set -x; $sh_c 'pip install git+https://github.com/treyhunner/django-simple-history.git@1.8.2#egg=django-simple-history' ) +                echo "-------------------------------------------------------------------------------"; +                cecho y "Installing python-secretary" +                echo ""; +                ( set -x; $sh_c 'pip install secretary==0.2.14' ) + +            fi +            ;; + +    esac      echo "-------------------------------------------------------------------------------"; -    echo "Installing Ishtar sources" +    cecho y "Installing Ishtar sources"      echo ""; -    mkdir -p $full_install_path -    cd $full_install_path -    ( set -x; git clone git://git.proxience.com/git/oook_replace.git 2> /dev/null ) +    cd $install_path +    if [ "$dist_version" == "wheezy" ]; then +        ( set -x; git clone https://nimn@gitlab.com/iggdrasil/oook_replace.git 2> /dev/null ) +    fi      ( set -x; git clone https://gitlab.com/iggdrasil/ishtar.git 2> /dev/null )      cd ishtar      git fetch 2> /dev/null      git checkout $version 2> /dev/null      mkdir -p $etc_path -    echo "PATH="$full_install_path > $etc_path"config" -    echo "DEFAULT_DB="$default_db >> $etc_path"config" -    echo "WEBSERVER="$webserver >> $etc_path"config" +    echo "ISHTAR_PATH="$full_install_path > $etc_path"config" +    echo "ISHTAR_DB="$default_db >> $etc_path"config" +    echo "ISHTAR_WEBSERVER="$webserver >> $etc_path"config" +    echo "# settings added to all instances" >> $etc_path"extra_settings.py" +    echo "" +    cecho g "*******************************************************************************" +    echo ""; +    cecho g "Installation done." +    cecho g "Base configuration stored in: "$etc_path"config"      echo "" -    echo "*******************************************************************************"; +    echo "You can edit "$etc_path"extra_settings.py to add Django settings to all new" +    echo "instances.";      echo ""; -    echo "Installation done. Base configuration stored in "$etc_path"config file." -    echo "Next you'll have to create an instance." +    cecho y "Next you will have to create an instance with: ./ishtar-prepare-instance"      echo "";  } diff --git a/install/ishtar-prepare-instance b/install/ishtar-prepare-instance new file mode 100755 index 000000000..e7ac1152a --- /dev/null +++ b/install/ishtar-prepare-instance @@ -0,0 +1,329 @@ +#!/bin/bash + +set -e + +cecho() { +  local code="\033[" +  case "$1" in +    black  | bk) color="${code}0;30m";; +    red    |  r) color="${code}1;31m";; +    green  |  g) color="${code}1;32m";; +    yellow |  y) color="${code}1;33m";; +    blue   |  b) color="${code}1;34m";; +    purple |  p) color="${code}1;35m";; +    cyan   |  c) color="${code}1;36m";; +    gray   | gr) color="${code}0;37m";; +    *) local text="$1" +  esac +  [ -z "$text" ] && local text="$color$2${code}0m" +  echo -e "$text" +} + +do_install_instance() { + +    NGINX_PORT=${NGINX_PORT-80} +    NGINX_AVAILABLE_PATH='/etc/nginx/sites-available' +    NGINX_ENABLE_PATH='/etc/nginx/sites-enabled' +    UWSGI_AVAILABLE_PATH='/etc/uwsgi/apps-available' +    UWSGI_ENABLE_PATH='/etc/uwsgi/apps-enabled' +    PG_VERSION=9.4 +    POSTGIS_VERSION=2.3.1 + +    echo "" +    cecho g "*******************************************************************************" +    cecho g "++++++                  Ishtar instance preparation script               ++++++" +    cecho g "*******************************************************************************" +    echo "" + +    # check user +    user="$(id -un 2>/dev/null || true)" + +    sh_c='sh -c' +    if [ "$user" != 'root' ]; then +        if command_exists sudo; then +            sh_c='sudo -E sh -c' +        elif command_exists su; then +            sh_c='su -c' +        else +            cecho r "  Error: this installer needs the ability to run commands as root." +            cecho r "  We are unable to find either "sudo" or "su" available to make this happen." +            exit 1 +        fi +    fi + +    export LANG=fr_FR.UTF-8 +    if [ "$(locale 2>&1 >/dev/null|wc -l)" != 0 ]; then +        cecho r "Unable to set LANG=$LANG properly" +        cecho "Try: 'dpkg-reconfigure locales' or install the 'locales-all' package" +        exit 1 +    fi + +    if [ ! -z '$CONFIG_PATH' ]; then +        CONFIG_PATH="/etc/ishtar/" +    fi + +    if [ ! -f $CONFIG_PATH/config ]; then +        echo ""; +        cecho r ""$CONFIG_PATH" is not a valid config file." +        echo "Have you properly install Ishtar sources?" +        echo "Run ishtar-install before this script."; +        echo ""; +        exit 1; +    fi + +    source $CONFIG_PATH/config + +    cd $ISHTAR_PATH + +    INSTANCES_FILE=$CONFIG_PATH/instances + +    if [ ! -f $INSTANCES_FILE ]; then +        touch $INSTANCES_FILE +    fi + +    if [ -z '$INSTANCE' ]; then +        if [ -d "$INSTANCE" ]; then +            cecho r "Sorry, $INSTANCE already exists." +            echo "Give another code name." +            exit 1 +        fi + +    else +        INSTANCE='' +        cat >&2 <<-'EOF' + +------------------------------------------------------------------------------- +  You should select a code name for this instance. This code name should have +  only lower alphanumeric characters, with no spaces, no accents and should not +  begin with an alphabetical character. The only special character allowed is +  "_". + +EOF +        while [ "$INSTANCE" == '' ] +        do +            cecho y "* Which instance code name? [my_ishtar_instance] " +            read choice +            if [ -z "$choice" ]; then +                INSTANCE='my_ishtar_instance' +            else +                INSTANCE=$choice +            fi +            if [ -d "$INSTANCE" ]; then +                echo "Sorry, $INSTANCE already exists. Give another name." +                INSTANCE='' +            fi +        done +    fi + +    if [ ! -z '$URL' ]; then +        URL='' +        cat >&2 <<-'EOF' + +------------------------------------------------------------------------------- +  You should select an url to join your instance. Only a full domain is +  accepted. Don't forget to set up your DNS to point this url name to this +  server. Only put the url not the protocol part (no http://). +  For instance: ishtar.mydomain.org + +EOF +        while [ "$URL" == '' ] +        do +            cecho y "* Which url? " +            read choice +            URL=$choice +        done +    fi + +    DEST=$ISHTAR_PATH + +        cat >&2 <<-'EOF' + +------------------------------------------------------------------------------- +EOF +    echo "Preparing ishtar instance: $INSTANCE under $DEST" +    echo "" +    # register instance +    echo "$INSTANCE" >> $INSTANCES_FILE + +    mkdir -p            /var/log/django +    chown root:www-data /var/log/django +    touch               "/var/log/django/ishtar-$INSTANCE.log" +    chown root:www-data "/var/log/django/ishtar-$INSTANCE.log" +    chmod g+w           "/var/log/django/ishtar-$INSTANCE.log" + + +    cecho y " * duplicate example_project into our instance" +    # Duplicate example_project into our instance: +    cd $ISHTAR_PATH +    cp -ra example_project $INSTANCE + +    rm $INSTANCE/settings.py +    ln -s $DEST/example_project/settings.py $DEST/$INSTANCE/settings.py + +    # Permissions: +    mkdir -p -m 755     "$INSTANCE/media" +    mkdir -p -m 755     "$INSTANCE/media/imported" +    mkdir -p -m 755     "$INSTANCE/media/upload" +    chown -R www-data:www-data "$INSTANCE/media" + +    # Preparing DB: +    DB_HOST=${ISHTAR_DB-127.0.0.1} +    DB_PORT=${ISHTAR_DB_PORT-5432} +    DB_PASSWORD=${DB_PASSWORD-''} +    DB_NAME="ishtar-$INSTANCE" + +    # Generate a password on the fly if none was specified: +    if [ -z "$DB_PASSWORD" ]; then +        DB_PASSWORD=$(apg -a 0 -M ncl -n 1 -x 10 -m 10) +    fi + +    export PG_VERSION DB_HOST DB_PORT DB_PASSWORD DB_NAME POSTGIS_VERSION +    su postgres <<'EOF' +      echo " * Checking template_postgis" +      if ! psql -l | grep -qs template_postgis; then +        echo "   - not present, creating" +        createdb -E UTF8 template_postgis +        psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis'" +        psql -q -d template_postgis -f /usr/share/postgresql/$PG_VERSION/extensions/postgis--$POSTGIS_VERSION.sql +        psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" +        psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;" +        psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" +      else +        echo "   - already present" +      fi + +      echo " * Checking database $DB_NAME" +      if ! psql -l | grep -qs "$DB_NAME"; then +        echo "   - not present, creating" +        createuser --echo --adduser --createdb --encrypted $DB_NAME +        psql --command "ALTER USER \""$DB_NAME"\" with password '"$DB_PASSWORD"';" +        createdb -T template_postgis --echo --owner $DB_NAME --encoding UNICODE $DB_NAME +        psql -d $DB_NAME -c "CREATE EXTENSION postgis;" +      else +        echo "   - already present" +      fi +EOF + +    ### LOCAL SETTINGS + +    cecho y " * creating config files" +    # Set some variables to avoid changing sed calls too much compared to +    # the initial install/install.sh script: +    INSTALL_PATH=$DEST +    INSTALL_PREFIX=$DEST +    APP_DIR="$DEST/$INSTANCE" +    DATE=`date +%F` +    SECRET_KEY=$(apg -a 0 -M ncl -n 1 -x 10 -m 40) + +    PORT_FILE=$CONFIG_PATH/last_uswgi_port + +    if [ -f $PORT_FILE ]; then +        UWSGI_PORT=`cat $PORT_FILE` +        UWSGI_PORT=`expr $UWSGI_PORT + 1` +    else +        UWSGI_PORT=8889 +    fi +    echo $UWSGI_PORT > $PORT_FILE + +    ### local_settings.py + +    sed -s "s|#APP_NAME#|$INSTANCE|g;\ +            s|#INSTALL_PATH#|$INSTALL_PATH|g;\ +            s|#DB_HOST#|$DB_HOST|g;\ +            s|#DB_NAME#|$DB_NAME|g;\ +            s|#DB_PORT#|$DB_PORT|g;\ +            s|#DB_PASSWORD#|$DB_PASSWORD|g;\ +            s|#URL#|$URL|g;\ +            s|#APP_DIR#|$APP_DIR|g;\ +            s|#SECRET_KEY#|$SECRET_KEY|g;" \ +        "install/local_settings.py.sample" > \ +        "$INSTANCE/local_settings.py" + +    if [ -f $CONFIG_PATH"extra_settings.py" ]; then +        cat $CONFIG_PATH"extra_settings.py" >> "$INSTANCE/local_settings.py" +    fi + +    ### UWSGI + +    sed -s "s|#APP_NAME#|$INSTANCE|g;\ +            s|#INSTALL_PREFIX#|$INSTALL_PREFIX|g;\ +            s|#URL#|$URL|g;\ +            s|#UWSGI_PORT#|$UWSGI_PORT|g;" \ +        "install/uwsgi.ini.template" > \ +        "$INSTANCE/uwsgi.ini" + +    ln -sf "$DEST/$INSTANCE/uwsgi.ini" \ +           "$UWSGI_AVAILABLE_PATH/ishtar-$INSTANCE.ini" +    ln -sf "$UWSGI_AVAILABLE_PATH/ishtar-$INSTANCE.ini" \ +           "$UWSGI_ENABLE_PATH/ishtar-$INSTANCE.ini" + +    ### NGINX + +    sed -s "s|#APP_NAME#|$INSTANCE|g;\ +            s|#UWSGI_PORT#|$UWSGI_PORT|g;\ +            s|#NGINX_PORT#|$NGINX_PORT|g;\ +            s|#INSTALL_PATH#|$INSTALL_PATH|g;\ +            s|#URL#|$URL|g;" \ +        "install/nginx.conf.template" > \ +        "$INSTANCE/nginx.conf" + +    ln -sf "$DEST/$INSTANCE/nginx.conf" \ +           "$NGINX_AVAILABLE_PATH/ishtar-$INSTANCE.conf" +    ln -sf "$NGINX_AVAILABLE_PATH/ishtar-$INSTANCE.conf" \ +           "$NGINX_ENABLE_PATH/ishtar-$INSTANCE.conf" + + +    cecho y " * collect static data" +    cd $INSTANCE +    ./manage.py collectstatic --noinput > /dev/null +    cd - + +    # only language available +    LOCALE=fr +    cecho y " * compile translations" +    for d in archaeological_* ishtar_common; do +        cd $d +        ../$INSTANCE/manage.py compilemessages -l $LOCALE +        cd - +    done + +    ### DB feeding +    cd $INSTANCE +    cecho y " * db feeding" +    cecho y "   - migrations" +    ./manage.py migrate + +    cecho y "   - loading fixtures" +    FIXTURES="$DEST/fixtures/initial_data-auth-fr.json $DEST/ishtar_common/fixtures/initial_data-fr.json $DEST/ishtar_common/fixtures/initial_importtypes-fr.json $DEST/archaeological_operations/fixtures/initial_data-fr.json $DEST/archaeological_context_records/fixtures/initial_data-fr.json $DEST/archaeological_files/fixtures/initial_data-fr.json $DEST/archaeological_finds/fixtures/initial_data-fr.json $DEST/archaeological_warehouse/fixtures/initial_data-fr.json" +    for data in $FIXTURES; do +        echo $data; +        ./manage.py loaddata $data; +    done + +    cecho y "   - create superuser" +    ./manage.py createsuperuser + +    cecho y "   - post install script" +    cd .. +    python ./install/post_install_script.py $INSTANCE $URL + +    cat >&2 <<-'EOF' + +------------------------------------------------------------------------------- +EOF +    cecho g "  Your instance has been configured." +    echo "" +    cecho g "   * instance name: "$INSTANCE +    cecho g "   * url: http://"$URL + +    cat >&2 <<-'EOF' + +    You should restart uwsgi and nginx: +EOF +    cecho y "systemctl restart uwsgi nginx" +    echo "" +    echo "  And then enjoy ishtar!" +    echo "" +} + +do_install_instance diff --git a/install/ishtar-update b/install/ishtar-update new file mode 100755 index 000000000..3e2797c76 --- /dev/null +++ b/install/ishtar-update @@ -0,0 +1,103 @@ +#!/bin/bash + +set -e + +cecho() { +  local code="\033[" +  case "$1" in +    black  | bk) color="${code}0;30m";; +    red    |  r) color="${code}1;31m";; +    green  |  g) color="${code}1;32m";; +    yellow |  y) color="${code}1;33m";; +    blue   |  b) color="${code}1;34m";; +    purple |  p) color="${code}1;35m";; +    cyan   |  c) color="${code}1;36m";; +    gray   | gr) color="${code}0;37m";; +    *) local text="$1" +  esac +  [ -z "$text" ] && local text="$color$2${code}0m" +  echo -e "$text" +} + +update_instances() { +    echo "" +    cecho g "*******************************************************************************" +    cecho g "++++++                  Ishtar instance update instances                 ++++++" +    cecho g "*******************************************************************************" +    echo "" + +    # check user +    user="$(id -un 2>/dev/null || true)" + +    sh_c='sh -c' +    if [ "$user" != 'root' ]; then +        if command_exists sudo; then +            sh_c='sudo -E sh -c' +        elif command_exists su; then +            sh_c='su -c' +        else +            cecho r "  Error: this installer needs the ability to run commands as root." +            cecho r "  We are unable to find either "sudo" or "su" available to make this happen." +            exit 1 +        fi +    fi + +    if [ ! -z '$CONFIG_PATH' ]; then +        CONFIG_PATH="/etc/ishtar/" +    fi + +    if [ ! -f $CONFIG_PATH/config ]; then +        echo ""; +        cecho r ""$CONFIG_PATH" is not a valid config file." +        echo "Have you properly install Ishtar sources?" +        echo "Run ishtar-install before this script."; +        echo ""; +        exit 1; +    fi + +    source $CONFIG_PATH/config + +    cd $ISHTAR_PATH + +    cecho g "Update Ishtar library from git repository" +    git pull + +    INSTANCES_FILE=$CONFIG_PATH/instances +    instances="$( (cat $INSTANCES_FILE 2>/dev/null || true) | xargs )" + +    if [ -n "$instances" ]; then +        translated='' +        for instance in $instances; do + +            if [ "$translated" == '' ]; then +                cecho g "* Compile translations" +                maybe_localized=$(cd $ISHTAR_PATH; find -maxdepth 2 -name 'locale') +                for candidate in $maybe_localized; do +                    if find $ISHTAR_PATH/$candidate -name '*.po' >/dev/null 2>&1; then +                        app=${candidate%%/locale} +                        (cd $ISHTAR_PATH/$app; python $ISHTAR_PATH/$instance/manage.py compilemessages) +                    fi +                done +                translated='true' +            fi + +            cd $ISHTAR_PATH/$instance +            cecho g "Instance: $instance" +            cecho y " * collect static" +            python manage.py collectstatic --noinput 2> /dev/null +            cecho y " * database migrations" +            python manage.py migrate + +        done +    fi +    echo "" +    cecho g "All instances have been updated" +    cat >&2 <<-'EOF' + +    You should restart uwsgi and nginx: +EOF +    cecho y "systemctl restart uwsgi nginx" +    echo "" +} + +update_instances diff --git a/install/local_settings.py.sample b/install/local_settings.py.sample index 459828c00..0a81fa68b 100644 --- a/install/local_settings.py.sample +++ b/install/local_settings.py.sample @@ -6,10 +6,8 @@ DEBUG_TOOLBAR = False  TEMPLATE_DEBUG = DEBUG  SQL_DEBUG = False -APP_NAME = u"#PROJECT_NAME#" -PROJECT_SLUG = u"#PROJECT_NAME#" +PROJECT_SLUG = "#APP_NAME#"  ROOT_URLCONF = '#APP_NAME#.urls' -STATIC_URL = '/static-#DATE#/'  SECRET_KEY = "#SECRET_KEY#"  LOGFILE = "/var/log/django/ishtar-#APP_NAME#.log" @@ -17,12 +15,12 @@ MEDIA_ROOT = "#APP_DIR#/media/"  ODT_TEMPLATE = "#INSTALL_PATH#/ishtar/ishtar_common/static/template.odt" +ALLOWED_HOSTS = ["#URL#"] +  ADMINS = (      # ('Your Name', 'your_email@domain.com'),  ) -MANAGERS = ADMINS -  DATABASES = {      'default': {          'ENGINE': 'django.contrib.gis.db.backends.postgis', @@ -33,11 +31,3 @@ DATABASES = {          'PASSWORD': '#DB_PASSWORD#',      }  } - -# choose the extensions to install -EXTRA_APPS = [ -    'archaeological_files', -    'archaeological_context_records', -    'archaeological_warehouse', -    'archaeological_finds', -] diff --git a/install/nginx.conf.template b/install/nginx.conf.template index dd236d113..15333393b 100644 --- a/install/nginx.conf.template +++ b/install/nginx.conf.template @@ -1,28 +1,18 @@  server {      listen #NGINX_PORT#;      server_name #URL#; -    root /srv/#DB_NAME#/ishtar/; +    root #INSTALL_PATH#;      access_log /var/log/django/#APP_NAME#-access.log;      error_log /var/log/django/#APP_NAME#-error.log;      client_max_body_size 20M; -    location /static-#DATE#/ { # STATIC_URL -        alias /srv/#DB_NAME#/ishtar/#APP_NAME#/static/; # STATIC_ROOT +    location /static/ { # STATIC_URL +        alias #INSTALL_PATH#/#APP_NAME#/static/; # STATIC_ROOT          expires 30d;      }      location /media/ { # MEDIA_URL -        alias /srv/#DB_NAME#/ishtar/#APP_NAME#/media/; # MEDIA_ROOT -        expires 30d; -    } - -    location /tinymce/ { -        alias /usr/share/tinymce/www/; -        expires 30d; -    } - -    location /javascript/ { -        alias /usr/share/javascript/; +        alias #INSTALL_PATH#/#APP_NAME#/media/; # MEDIA_ROOT          expires 30d;      } diff --git a/install/post_install_script.py b/install/post_install_script.py new file mode 100644 index 000000000..141b738d0 --- /dev/null +++ b/install/post_install_script.py @@ -0,0 +1,28 @@ +import sys +import os +import django + +sys.path.append(os.path.abspath('.')) + +app_name, url = sys.argv[1], sys.argv[2] +os.environ.setdefault("DJANGO_SETTINGS_MODULE", app_name + ".settings") +django.setup() + +from django.contrib.sites.models import Site +from ishtar_common.models import IshtarSiteProfile + +q = Site.objects.filter(domain='example.com') + +if q.count(): +    site = q.get() +    site.domain = url +    site.name = url +    site.save() + +q = IshtarSiteProfile.objects.filter(slug='default') + +if q.count(): +    profile = q.get() +    profile.label = app_name +    profile.slug = app_name +    profile.save() diff --git a/install/uninstall.sh b/install/uninstall.sh deleted file mode 100755 index 71a5dae17..000000000 --- a/install/uninstall.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# only lower alpha-numeric char and '_' and must start with a letter -[ $APP_NAME ] || ( echo 'APP_NAME empty. Default to: "default".' ; ); -APP_NAME=${APP_NAME-default} -# don't forget the trailing slash -INSTALL_PREFIX=/srv/ - -read -r -p "Are you sure to delete "$APP_NAME" app? [y/N] " response -response=${response,,}    # tolower -if [[ $response =~ ^(yes|y)$ ]] -then -    echo '* deleting '$APP_NAME; -else -    echo "canceled"; -    exit; -fi - -# default for debian -UWSGI_AVAILABLE_PATH='/etc/uwsgi/apps-available/' -UWSGI_ENABLE_PATH='/etc/uwsgi/apps-enabled/' -NGINX_AVAILABLE_PATH='/etc/nginx/sites-available/' -NGINX_ENABLE_PATH='/etc/nginx/sites-enabled/' - -DB_NAME='ishtar'$APP_NAME -INSTALL_PATH=$INSTALL_PREFIX$DB_NAME - -rm -f $UWSGI_AVAILABLE_PATH$APP_NAME'.ini' -rm -f $UWSGI_ENABLE_PATH$APP_NAME'.ini' -rm -f $NGINX_AVAILABLE_PATH$APP_NAME'.conf' -rm -f $NGINX_ENABLE_PATH$APP_NAME'.conf' - -rm -rf $INSTALL_PATH - -echo "All file cleaned." -echo "You can delete database '"$DB_NAME"' to fully clean your installation." diff --git a/install/uwsgi.ini.template b/install/uwsgi.ini.template index 7a20c058c..51a4c5b7f 100644 --- a/install/uwsgi.ini.template +++ b/install/uwsgi.ini.template @@ -2,7 +2,7 @@  # variables  projectname = #APP_NAME#  projectdomain = #URL# -base = /srv/#DB_NAME#/ishtar/ +base = #INSTALL_PREFIX#  # config  plugins = python | 
