diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-01-31 18:25:53 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-04 18:49:51 +0100 |
commit | 2577f824b97acdc115f98777aa6de32adf018581 (patch) | |
tree | 89c5db0323aafeb1ccebfa6322644a07e44c31bb | |
parent | f59ca6c32aed139de7367f2bd7b933dcfd510719 (diff) | |
download | Ishtar-2577f824b97acdc115f98777aa6de32adf018581.tar.bz2 Ishtar-2577f824b97acdc115f98777aa6de32adf018581.zip |
Debian: color for postinst configure
-rw-r--r-- | debian/python3-django-ishtar.postinst | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/debian/python3-django-ishtar.postinst b/debian/python3-django-ishtar.postinst index dc43cb0ed..833243495 100644 --- a/debian/python3-django-ishtar.postinst +++ b/debian/python3-django-ishtar.postinst @@ -3,6 +3,23 @@ set -e #set -x +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 "$text" +} + DATA_DIR=/srv/ishtar CONFIG_PATH=/etc/ishtar INSTANCES_FILE=$CONFIG_PATH/instances @@ -16,14 +33,14 @@ case "$1" in . $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." + cecho r "Unable to set LANG=$LANG properly" + cecho y "Try: 'dpkg-reconfigure locales' or install the 'locales-all' package." + cecho y "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" + cecho g "Updading instances found in $INSTANCES_FILE: $instances" messages_compiled=""; for instance in $instances; do if [ ! $messages_compiled ]; then @@ -32,24 +49,26 @@ case "$1" in fi # The upgrade procedure below was built from the "update" # target and its dependencies in the upstream Makefile: - echo "updating $instance" + cecho g "Updating $instance" cd $DATA_DIR/$instance # migrate python3 manage.py migrate # "collectstatic" python3 manage.py collectstatic --noinput - echo "updating $instance: OK" + cecho g "Updating $instance: OK" done - echo "updating all instances: OK" + cecho g "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" + cecho g "Restarting uwsgi and nginx: OK" else - echo "found no instances to upgrade in $INSTANCES_FILE" + cecho g "Found no instances to update in $INSTANCES_FILE" + cecho g "To create a new instance:" + cecho y " ishtar-prepare-instance" fi ;; |