#!/bin/sh set -e set -x DATA_DIR=/srv/ishtar CONFIG_PATH=/etc/ishtar INSTANCES_FILE=$CONFIG_PATH/instances case "$1" in configure) mkdir -p $CONFIG_PATH if [ ! -f $CONFIG_PATH/config ]; then cp /usr/share/python3-django-ishtar/install/config.template $CONFIG_PATH/config ; fi . $CONFIG_PATH/config export LANG=$ISHTAR_LOCALE.UTF-8 if [ "$(locale 2>&1 >/dev/null|wc -l)" != 0 ]; then echo r "Unable to set LANG=$LANG properly" echo "Try: 'dpkg-reconfigure locales' or install the 'locales-all' package." echo "If you want to use another locale, modify /etc/ishtar/config properly." exit 1 fi instances="$( (cat $INSTANCES_FILE 2>/dev/null || true) | xargs )" if [ -n "$instances" ]; then echo "updading instances found in $INSTANCES_FILE: $instances" messages_compiled=""; for instance in $instances; do if [ ! $messages_compiled ]; then (cd $DATA_DIR; python3 $DATA_DIR/$instance/manage.py compilemessages); messages_compiled="ok"; fi # The upgrade procedure below was built from the "update" # target and its dependencies in the upstream Makefile: echo "updating $instance" cd $DATA_DIR/$instance # migrate python3 manage.py migrate # "collectstatic" python3 manage.py collectstatic --noinput echo "updating $instance: OK" done echo "updating all instances: OK" # the assumption is that nginx and uwsgi were configured # through ishtar-prepare-instance, so let's restart them # unconditionally: invoke-rc.d uwsgi restart invoke-rc.d nginx restart echo "restarting uwsgi and nginx: OK" else echo "found no instances to upgrade in $INSTANCES_FILE" fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac