summaryrefslogtreecommitdiffstats
path: root/remote/rootfs
diff options
context:
space:
mode:
authorJonathan Bauer2013-07-31 17:24:08 +0200
committerJonathan Bauer2013-07-31 17:24:08 +0200
commit7974d03b84aa772e135773510879f67bf12252ff (patch)
tree8248a541bf8f3973d34d3a82e2d5f10d986f76d9 /remote/rootfs
parentrestruct (diff)
downloadtm-scripts-7974d03b84aa772e135773510879f67bf12252ff.tar.gz
tm-scripts-7974d03b84aa772e135773510879f67bf12252ff.tar.xz
tm-scripts-7974d03b84aa772e135773510879f67bf12252ff.zip
added download of config.tgz to activate-sysconfig and moved it to stage31
Diffstat (limited to 'remote/rootfs')
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/bin/activate-sysconfig67
1 files changed, 67 insertions, 0 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig
new file mode 100755
index 00000000..bfda70e1
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# first a few variables
+CONFIG="/mnt/opt/openslx/config"
+
+# parse kernel command line to determine the URL
+URL="$(grep -o -E "slxconfig=\S+" /proc/cmdline | cut -c 11-)"
+if [ -z "$URL" ]; then
+ echo "Error - 'slxconfig=' not found in command line, or empty"
+ exit 1
+fi
+
+#########################################################################
+#
+# Helper function to download given FILE_URL under TARGET_PATH
+#
+# Usage:
+# download $FILE_URL $TARGET_PATH
+#
+
+download() {
+ [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguements, $# given." \
+ && exit 1
+
+ local FILE_URL="$1"
+ local TARGET_PATH="$2"
+
+ wget -T 5 -q -O "$TARGET_PATH" "$FILE_URL"
+ RET=$?
+ if [ "x$RET" != "x0" ]; then
+ echo "Error - downloading '$FILE_URL' via wget failed. Exit Code: $RET"
+ exit 1
+ else
+ echo "Successfully downloaded '$FILE_URL'."
+ fi
+
+ return 0
+}
+
+#########################################################################
+#
+#
+# This first part downloads the config containing environment variables
+#
+#
+
+[ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \
+ && echo "Config already fetched." && exit 0
+
+download "$URL" "$CONFIG-remote" || exit 1
+
+echo "# Config fetched from $URL" >> "$CONFIG"
+echo "#_RCONFIG_TAG" >> "$CONFIG"
+cat "${CONFIG}-remote" >> "$CONFIG"
+
+#########################################################################
+#
+#
+# This part downloads the config.tgz and unpacks it to $1
+#
+#
+
+[ -e "$CONFIG.tgz" ] && echo "config.tgz already downloaded." && exit 0
+download "$URL.tgz" "$CONFIG.tgz" || exit 1
+
+tar xf "$CONFIG.tgz" -C /mnt || { echo "Could not untar $CONFIG.tgz to /mnt"; exit 1; }
+exit 0