diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-01-31 18:25:53 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-01-09 18:05:36 +0100 | 
| commit | f71c4bb8360b7de51235dd97c9350c7bd1bd9a18 (patch) | |
| tree | 2d7a009cf9858ade1d0f72846ca5f642c8456fe0 | |
| parent | 425ce661fcc8c4426d5389b8730e363b98574af8 (diff) | |
| download | Ishtar-f71c4bb8360b7de51235dd97c9350c7bd1bd9a18.tar.bz2 Ishtar-f71c4bb8360b7de51235dd97c9350c7bd1bd9a18.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      ;; | 
