diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-05-03 11:05:54 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-05-03 11:05:54 +0200 |
commit | 8ddff89ce0ed55757d76b58fe1f9a0395685839f (patch) | |
tree | 4b07396d1ae97040bd899428264ca6d8aa148cab /install/ishtar-update | |
parent | 412430fceca4ba47e5ff6483f80e602047301e75 (diff) | |
download | Ishtar-8ddff89ce0ed55757d76b58fe1f9a0395685839f.tar.bz2 Ishtar-8ddff89ce0ed55757d76b58fe1f9a0395685839f.zip |
Update script
Diffstat (limited to 'install/ishtar-update')
-rwxr-xr-x | install/ishtar-update | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/install/ishtar-update b/install/ishtar-update new file mode 100755 index 000000000..b6ed4f3bb --- /dev/null +++ b/install/ishtar-update @@ -0,0 +1,91 @@ +#!/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 + git pull + + 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 + + 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 +} + +update_instances |