summaryrefslogtreecommitdiffstats
path: root/install-all
diff options
context:
space:
mode:
authorSimon Rettberg2016-06-10 11:56:10 +0200
committerSimon Rettberg2016-06-10 11:56:10 +0200
commitca016030a647f05b9dbf7edd590975efe09c45a4 (patch)
treea447eb04d602c21cc90410abf08517e11c56a387 /install-all
parentRemove remaining references to schema version (diff)
downloadslx-admin-ca016030a647f05b9dbf7edd590975efe09c45a4.tar.gz
slx-admin-ca016030a647f05b9dbf7edd590975efe09c45a4.tar.xz
slx-admin-ca016030a647f05b9dbf7edd590975efe09c45a4.zip
[install-all] cmdline script to install/update database
Diffstat (limited to 'install-all')
-rwxr-xr-xinstall-all53
1 files changed, 53 insertions, 0 deletions
diff --git a/install-all b/install-all
new file mode 100755
index 00000000..42f8e5e4
--- /dev/null
+++ b/install-all
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+FILE=$(mktemp)
+if [ -z "$FILE" ]; then
+ echo "Something's fishy: No temp file!"
+ exit 1
+fi
+
+trap "rm -f -- '$FILE'" EXIT SIGINT SIGTERM
+
+START=$(php install.php | grep -m1 '^MODULE=' | cut -d= -f2-)
+
+if [ -z "$START" ]; then
+ echo "Cannot install slxadmin - did you configure the DB access properly?"
+ exit 1
+fi
+
+echo "Started with $START"
+
+declare -A COUNTER
+
+COUNTER["$START"]=1
+
+NEXT=$START
+RETRY=0
+while true; do
+ php install.php "$NEXT" > "$FILE"
+ MODULE=$(grep -m1 '^MODULE=' "$FILE" | cut -d= -f2-)
+ if [ -z "$MODULE" ]; then
+ echo "Barfed after $NEXT - no module name found in next run"
+ exit 1
+ fi
+ echo "Next module was ${MODULE}..."
+ (( COUNTER["$MODULE"]++ ))
+ if [ ${COUNTER["$MODULE"]} -gt 3 ]; then
+ echo "Iterated too many times"
+ exit 1
+ fi
+ STATUS=$(grep -m1 '^STATUS=' "$FILE" | cut -d= -f2-)
+ echo "Result: $STATUS"
+ if [ -z "$STATUS" ] || [ "$STATUS" = "UPDATE_RETRY" ]; then
+ RETRY=1
+ fi
+ if [ "$MODULE" = "$START" ]; then
+ if [ "$RETRY" = "0" ]; then
+ break
+ fi
+ RETRY=0
+ fi
+ NEXT=$MODULE
+done
+echo "Done."
+