diff options
author | Cyril Brulebois <cyril@debamax.com> | 2016-04-03 05:59:43 +0200 |
---|---|---|
committer | Cyril Brulebois <cyril@debamax.com> | 2016-04-03 05:59:43 +0200 |
commit | 9a33bd76774f1b726792fd0581280823dc514613 (patch) | |
tree | 23a45d6fdf8f0438e0ea1d3d3257813252fc61d9 /install | |
parent | 4f4ea768d9d72b96bcf826c525ed1b066191b11b (diff) | |
parent | e8a39800e8d11ac63c3ed53e95c0a3003ce578a0 (diff) | |
download | Ishtar-9a33bd76774f1b726792fd0581280823dc514613.tar.bz2 Ishtar-9a33bd76774f1b726792fd0581280823dc514613.zip |
Merge branch 'better-install' into release-v4
Diffstat (limited to 'install')
-rwxr-xr-x | install/install.sh | 32 | ||||
-rw-r--r-- | install/nginx.conf.template | 6 | ||||
-rw-r--r-- | install/uwsgi.ini.template | 2 |
3 files changed, 26 insertions, 14 deletions
diff --git a/install/install.sh b/install/install.sh index 92d0684c6..42d337c0d 100755 --- a/install/install.sh +++ b/install/install.sh @@ -41,7 +41,10 @@ UWSGI_PORT=${UWSGI_PORT-8891} NGINX_PORT=${NGINX_PORT-80} # don't forget the trailing slash -INSTALL_PREFIX=/srv/ +INSTALL_PREFIX=${INSTALL_PREFIX-/srv/} +if ! echo "$INSTALL_PREFIX" | grep -qs '/$'; then + INSTALL_PREFIX="$INSTALL_PREFIX/" +fi # if a virtualenv is used put the full path of the python to use PYTHON=python @@ -62,22 +65,25 @@ NGINX_ENABLE_PATH='/etc/nginx/sites-enabled/' echo "* installing dependencies" +APT_GET=${APT_GET-apt-get} +PIP=${PIP-pip} + if [ $DB_HOST = "127.0.0.1" ]; then - apt-get -q -y install postgresql postgresql-$PG_VERSION-postgis postgresql 2> /dev/null > /dev/null + $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 git apg python-pip 2> /dev/null > /dev/null -apt-get -q -y install python python-django \ +$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 +$APT_GET -q -y install uwsgi uwsgi-plugin-python nginx memcached 2> /dev/null > /dev/null -pip install$PIP_OPTIONS BeautifulSoup4==4.3.2 +$PIP install$PIP_OPTIONS BeautifulSoup4==4.3.2 if [ -z "$DB_PASSWORD" ] then @@ -89,7 +95,7 @@ fi DB_NAME='ishtar'$APP_NAME INSTALL_PATH=$INSTALL_PREFIX$DB_NAME DATE=`date +%F` -CDIR=`pwd` +CDIR=`readlink -f $(dirname $0)` SECRET_KEY=`apg -a 0 -M ncl -n 6 -x 10 -m 40 |head -n 1` if [ $DB_HOST = '127.0.0.1' ] @@ -119,7 +125,7 @@ fi echo '* get sources' -mkdir $INSTALL_PATH +mkdir -p $INSTALL_PATH mkdir $INSTALL_PATH'/conf' cd $INSTALL_PATH @@ -161,7 +167,7 @@ sed -s "s|#APP_NAME#|$APP_NAME|g;\ ln -s $INSTALL_PATH'/conf/local_settings.py' $APP_DIR'/local_settings.py' # rights -mkdir $APP_DIR'/media' +mkdir -p $APP_DIR'/media' chown -R root:www-data $APP_DIR'/media' chmod -R g+w $APP_DIR'/media' @@ -235,13 +241,16 @@ $PYTHON ./manage.py migrate --fake 2> /dev/null > /dev/null echo '* uwsgi configuration' +# NOTE: Replacing #INSTALL_PREFIX#/ is done on purpose, since we +# ensured that variable has a trailing slash. sed -s "s|#APP_NAME#|$APP_NAME|g;\ s|#DB_NAME#|$DB_NAME|g;\ + s|#INSTALL_PREFIX#/|$INSTALL_PREFIX|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' > \ +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' \ @@ -254,11 +263,14 @@ service uwsgi restart echo '* nginx configuration' +# NOTE: Replacing #INSTALL_PREFIX#/ is done on purpose, since we +# ensured that variable has a trailing slash. 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|#INSTALL_PREFIX#/|$INSTALL_PREFIX|g;\ s|#URL#|$URL|g;" $CDIR'/nginx.conf.template' > \ $INSTALL_PATH'/conf/nginx.conf' ln -s $INSTALL_PATH'/conf/nginx.conf' \ diff --git a/install/nginx.conf.template b/install/nginx.conf.template index c41018786..8df09e859 100644 --- a/install/nginx.conf.template +++ b/install/nginx.conf.template @@ -1,18 +1,18 @@ server { listen #NGINX_PORT#; server_name #URL#; - root /srv/#DB_NAME#/ishtar/; + root #INSTALL_PREFIX#/#DB_NAME#/ishtar/; 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 + alias #INSTALL_PREFIX#/#DB_NAME#/ishtar/#APP_NAME#/static/; # STATIC_ROOT expires 30d; } location /media/ { # MEDIA_URL - alias /srv/#DB_NAME#/ishtar/#APP_NAME#/media/; # MEDIA_ROOT + alias #INSTALL_PREFIX#/#DB_NAME#/ishtar/#APP_NAME#/media/; # MEDIA_ROOT expires 30d; } diff --git a/install/uwsgi.ini.template b/install/uwsgi.ini.template index 7a20c058c..dd8f00480 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#/#DB_NAME#/ishtar/ # config plugins = python |