summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinstall/ishtar-update91
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