diff options
author | Jonathan Bauer | 2017-08-04 17:38:18 +0200 |
---|---|---|
committer | Jonathan Bauer | 2017-08-04 17:38:18 +0200 |
commit | 2a8adf44f06227da6ff260d258f1a39c2637fdfd (patch) | |
tree | 6d242674c4c9f3c4f692e6d50589f047903fb208 /core/rootfs/rootfs-stage32/data | |
parent | [nvidia_*] Update to 384.59 (diff) | |
download | mltk-2a8adf44f06227da6ff260d258f1a39c2637fdfd.tar.gz mltk-2a8adf44f06227da6ff260d258f1a39c2637fdfd.tar.xz mltk-2a8adf44f06227da6ff260d258f1a39c2637fdfd.zip |
[rfs-s32] optimize slx addon setup
download the sqfs asap and only wait for tmp to append them to
the rest of the aufs
Diffstat (limited to 'core/rootfs/rootfs-stage32/data')
6 files changed, 100 insertions, 10 deletions
diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/download-slx-addon@.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/download-slx-addon@.service new file mode 100644 index 00000000..cb84287d --- /dev/null +++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/download-slx-addon@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Download SLX addon %I +DefaultDependencies=no +Wants=setup-slx-addon@%i.service +Before=setup-slx-addon@%i.service + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-download_slx_addons %I +RemainAfterExit=yes diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/download-slx-addons.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/download-slx-addons.service new file mode 100644 index 00000000..61627ff8 --- /dev/null +++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/download-slx-addons.service @@ -0,0 +1,9 @@ +[Unit] +Description=Download SLX addons +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-download_slx_addons +RemainAfterExit=yes + diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/download-slx-addons.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/download-slx-addons.service new file mode 120000 index 00000000..26de543e --- /dev/null +++ b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/download-slx-addons.service @@ -0,0 +1 @@ +../download-slx-addons.service
\ No newline at end of file diff --git a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service b/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service deleted file mode 120000 index 415050b5..00000000 --- a/core/rootfs/rootfs-stage32/data/etc/systemd/system/sysinit.target.wants/setup-slx-addons.service +++ /dev/null @@ -1 +0,0 @@ -../setup-slx-addons.service
\ No newline at end of file diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-download_slx_addons b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-download_slx_addons new file mode 100755 index 00000000..30f7432f --- /dev/null +++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-download_slx_addons @@ -0,0 +1,62 @@ +#!/bin/bash +# Needs full bash +# +# Script to be called by systemd +# +# 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; } + +# source functions.inc for the download function +. /opt/openslx/inc/functions || { echo "/opt/openslx/inc/functions not found!"; exit 1337; } + +# quick fix for the missing FUTURE_ROOT needed by /opt/openslx/etc/functions.inc +export FUTURE_ROOT="/" + +# 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." + #[ -z "${SLX_KCL_SERVERS}" ] && SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") +fi + +# read base slx servers from cmdline +BASE_MOUNT_POINT="/opt/openslx/mnt" +DOWNLOAD_DEST="/run/addons" +mkdir -p "$DOWNLOAD_DEST" || { echo "Failed to create $DOWNLOAD_DEST"; exit 1; } + +###################################################################################### +# +# DOWNLOAD ALL ADDONS +# +if [ $# -eq 0 ]; then + [ -z "${SLX_ADDONS}" ] && { echo "No addons configured. Nothing to do :-)."; exit 0; } + for ADDON in ${SLX_ADDONS}; do + systemctl start "download-slx-addon@$ADDON.service" & + done +fi +## +# DOWNLOAD SINGLE ADDON +if [ $# -eq 1 ]; then + ADDON="$1" + ADDON_TARGET_PATH="${DOWNLOAD_DEST}/$(basename "$ADDON").sqfs" + if ! download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}"; then + slxlog --echo "addon-download" "Download of '${HTTP_BASE_PATH}/${ADDON}.sqfs' failed." + exit 1 + fi +fi + +[ $# -gt 1 ] && { echo "$0 needs 0 or 1 arguments! $# given."; exit 1; } + +exit 0 + diff --git a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons index 8d4d2d1a..f49d1805 100755 --- a/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons +++ b/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_slx_addons @@ -32,8 +32,9 @@ fi # read base slx servers from cmdline BASE_MOUNT_POINT="/opt/openslx/mnt" -DOWNLOAD_DEST="/tmp/addons" -mkdir -p "$DOWNLOAD_DEST" || { echo "Failed to create $DOWNLOAD_DEST"; exit 1; } +DOWNLOAD_DEST="/run/addons" +FINAL_DEST="/tmp/addons" +mkdir -p "$FINAL_DEST" || { echo "Failed to create $FINAL_DEST"; exit 1; } ###################################################################################### # @@ -54,19 +55,27 @@ fi if [ $# -eq 1 ]; then ADDON="$1" - - # download the addon from the given URL - ADDON_TARGET_PATH="${DOWNLOAD_DEST}/$(basename "$ADDON").sqfs" - if ! download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}"; then - slxlog --echo "addon-download" "Download of '${HTTP_BASE_PATH}/${ADDON}.sqfs' failed." + # check that is was properly downloaded + ADDON_PATH="${DOWNLOAD_DEST}/$(basename $ADDON.sqfs)" + if [ ! -f "${ADDON_PATH}" ]; then + slxlog --echo "addon-setup" "Addon squashfs not found under: '${ADDON_PATH}'" exit 1 fi + # do we have tmp? + if mount | grep -q '^/dev/.*on /tmp type'; then + # it was there, so move it to /tmp that we should have by now + if mv "${ADDON_PATH}" "${FINAL_DEST}/$(basename $ADDON.sqfs)"; then + ADDON_PATH="${FINAL_DEST}/$(basename $ADDON.sqfs)" + else + slxlog --echo "addon-setup" "Failed to move '$ADDON' from $DOWNLOAD_DEST to $FINAL_DEST. Keeping it in RAM" + fi + fi # now mount it to $BASE_MOUNT_POINT/<addon-name> ADDON_MOUNT_POINT="${BASE_MOUNT_POINT}/$(basename "$ADDON")" mkdir -p "$ADDON_MOUNT_POINT" - mount -t squashfs -o ro "$ADDON_TARGET_PATH" "$ADDON_MOUNT_POINT" || \ - { slxlog --echo "addon-mount" "Failed to mount $ADDON_TARGET_PATH."; exit 1; } + mount -t squashfs -o ro "$ADDON_PATH" "$ADDON_MOUNT_POINT" || \ + { slxlog --echo "addon-mount" "Failed to mount $ADDON_PATH."; exit 1; } # now append it to / echo "Appending ${ADDON_MOUNT_POINT} to /" |