diff options
| author | Jonathan Bauer | 2013-08-22 15:27:59 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2013-08-22 15:27:59 +0200 |
| commit | b195ea20a53c5c7c5c5cbc19aefdba7e70588e51 (patch) | |
| tree | 1ec24d58a41d5ecea1b7a2d181ea95e36facceca /remote/rootfs | |
| parent | [rootfs-stage31] removed sourcing of /etc/functions.inc since it suffices to ... (diff) | |
| download | tm-scripts-b195ea20a53c5c7c5c5cbc19aefdba7e70588e51.tar.gz tm-scripts-b195ea20a53c5c7c5c5cbc19aefdba7e70588e51.tar.xz tm-scripts-b195ea20a53c5c7c5c5cbc19aefdba7e70588e51.zip | |
[rootfs-stage32] new service to setup slx addons separatly. Adapted systemd-setup_slx_addons to either go through all the addons found in the config file if no argument is given, or to setup one addon if one argument is given. That way we can see if/which addons are set up and/or which failed.
Diffstat (limited to 'remote/rootfs')
| -rw-r--r-- | remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service | 7 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons | 49 |
2 files changed, 47 insertions, 9 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..20909813 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service @@ -0,0 +1,7 @@ +[Unit] +Description=Setup SLX addon %i + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-setup_slx_addons %I +RemainAfterExit=yes diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons index a5dc9965..e482cfb6 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons @@ -4,31 +4,60 @@ # # Downloads and appends addons per sqfs/aufs. # +###################################################################################### # +# Two modes for this script: +# - without any arguments, it will just go through the list of addons to +# setup as given through the OpenSLX configuration file +# - with an argument, it will setup the addon given as $1 +# +# +###################################################################################### +# read global OpenSLX config . /opt/openslx/config || { echo "Could not source config!"; exit 23; } [ -z "${SLX_ADDONS}" ] && { echo "No addons configured. Nothing to do :-)."; exit 0; } +# source functions.inc for the download function . /opt/openslx/etc/functions.inc || { echo "functions.inc not found!"; exit 1337; } +# quick fix for the missing FUTURE_ROOT needed by /opt/openslx/etc/functions.inc export FUTURE_ROOT="/" -# read openslx config +# read openslx config, especially servers given by SLX_KCL_SERVERS and SLX_CONFIG_SERVERS if [ -z "${SLX_CONFIG_SERVERS}" ]; then echo "SLX_CONFIG_SERVERS is not set in /opt/openslx/config. Will only try the base servers from the cmdline." - if [ -z "${SLX_KCL_SERVERS}" ]; then - SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") - fi + [ -z "${SLX_KCL_SERVERS}" ] && SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") fi # read base slx servers from cmdline SLX_BASE_PATH=$(read_from_cmdline "slxbase") - SLX_BASE_MNT="/opt/openslx/mnt" SYS_TMP="/tmp/addons" mkdir -p "$SYS_TMP" || { echo "Failed to create $SYS_TMP"; exit 1; } -for ADDON in ${SLX_ADDONS}; do +###################################################################################### +# +# NO ARGUMENTS -> LOOP OVER ALL ADDONS +# + +if [ $# == 0 ]; then + for ADDON in ${SLX_ADDONS}; do + systemctl start setup-slx-addon@$ADDON + done +fi + +###################################################################################### +# +# WITH ARGUMENTS -> SETUP ADDON +# + +if [ $# == 1 ]; then + ADDON="$1" + + # sanity check + [[ ! "$SLX_ADDONS" == *"$ADDON"* ]] && { echo "$ADDON is not listed in SLX_ADDONS of your config file. Skipping it." && exit 1; } + # download the addon from the given URL ADDON_TARGET_PATH="${SYS_TMP}/$(basename "$ADDON").sqfs" download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}" @@ -37,17 +66,19 @@ for ADDON in ${SLX_ADDONS}; do ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename "$ADDON")" 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; } + mount -t squashfs "$ADDON_TARGET_PATH" "$ADDON_MOUNT_POINT" || { echo "Failed to mount $ADDON_TARGET_PATH." && exit 1; } # now append it to / echo "Appending ${ADDON_MOUNT_POINT} to /" - mount -o "remount,append:${ADDON_MOUNT_POINT}=ro" / || { echo "Fail." && exit 1; } + mount -o "remount,append:${ADDON_MOUNT_POINT}=ro" / || { echo "Failed to append ${ADDON_MOUNT_POINT} to the aufs." && exit 1; } # Run post-hook if available if [ -x "$ADDON_MOUNT_POINT/addon-init" ]; then echo "Running addon initialization script..." "$ADDON_MOUNT_POINT/addon-init" || echo "Warning: Could not execute addon-init of $ADDON" fi -done +fi + +[ $# -gt 1 ] && { echo "Error - $0 only takes no or one argument. $# given." && exit 1; } exit 0 |
