summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2013-08-14 16:30:25 +0200
committerJonathan Bauer2013-08-14 16:30:25 +0200
commit65a8972cafc77d3658e911f71db365cfd4f023a5 (patch)
tree9222f8535c9e4a80c821b7a300902ad5f47df725
parentMerge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff)
downloadtm-scripts-65a8972cafc77d3658e911f71db365cfd4f023a5.tar.gz
tm-scripts-65a8972cafc77d3658e911f71db365cfd4f023a5.tar.xz
tm-scripts-65a8972cafc77d3658e911f71db365cfd4f023a5.zip
[rootfs-stage32] new systemd service and script to download, mount and append an addon (in sqfs) to the current /
-rw-r--r--remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service8
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addon35
2 files changed, 43 insertions, 0 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service
new file mode 100644
index 00000000..af639976
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Download, mount and append SLX addon %I
+After=sysinit.target
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-setup_slx_addon %I
+RemainAfterExit=yes
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addon b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addon
new file mode 100755
index 00000000..0b52922a
--- /dev/null
+++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addon
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# Script to be called by systemd
+#
+# Downloads and appends addons per sqfs/aufs.
+#
+#
+
+# This script requires the addon to setup as its first parameter
+
+[ "x$1" == "x" ] && { echo "$0 requires the addon as parameter. None given." && exit 1; }
+ADDON="$1"
+
+# read openslx config
+. /opt/openslx/config
+[ -z "${SLX_ADDONS_BASE_URL}" ] && { echo "SLX_ADDONS_BASE_URL is not set in /opt/openslx/config." && exit 1; }
+[ -z "${SLX_ADDONS_LIST}" ] && { echo "SLX_ADDONS_LIST is not set in /opt/openslx/config." && exit 1; }
+
+SLX_BASE_MNT="/opt/openslx/mnt"
+SYS_TMP="/tmp"
+
+# download the addon from the given URL
+ADDON_TARGET_PATH="${SYS_TMP}/$(basename $(echo ${ADDON})).sqfs"
+echo "Downloading $SLX_ADDONS_BASE_URL/${ADDON}.sqfs to ${ADDON_TARGET_PATH}"
+wget -T 5 -q -O "${ADDON_TARGET_PATH}" "${SLX_ADDONS_BASE_URL}/${ADDON}.sqfs"|| { echo "Failed to download." && exit 1; }
+
+# now mount it to $SLX_MNT/<addon-name>
+ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename $(echo ${ADDON})|awk -F "." '{print $1}')"
+mkdir -p "$ADDON_MOUNT_POINT"
+echo "Mounting ${ADDON_TARGET_PATH} to ${ADDON_MOUNT_POINT}"
+mount -t squashfs "$ADDON_TARGET_PATH" ${ADDON_MOUNT_POINT} || { echo "Failed to mount." && exit 1; }
+
+# now append it to /
+echo "Appending ${ADDON_MOUNT_POINT} to /"
+mount -o remount,append:${ADDON_MOUNT_POINT}=ro / || { echo "Fail." && exit 1; }