From 65971818a573c47f182de461092d60bf1c63cc2b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 16:28:42 +0200 Subject: [rootfs-stage32] Make it possible to run a script after adding an addon to the aufs stack. Call it addon-init and place it in the root directory of your addon [vmplayer] Add such an addon-init script that will take care of setting up the vmplayer environment --- remote/modules/vmplayer/data/addon-init | 5 +++++ remote/rootfs/rootfs-stage31/data/bin/setup_stage32 | 4 ++++ .../data/opt/openslx/scripts/systemd-setup_slx_addons | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 remote/modules/vmplayer/data/addon-init (limited to 'remote') diff --git a/remote/modules/vmplayer/data/addon-init b/remote/modules/vmplayer/data/addon-init new file mode 100755 index 00000000..01acb3b4 --- /dev/null +++ b/remote/modules/vmplayer/data/addon-init @@ -0,0 +1,5 @@ +#!/bin/sh + +systemctl daemon-reload +systemctl start vmware + diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index 151617bc..bc00b830 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -45,3 +45,7 @@ mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || d mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." FUTURE_ROOT="/mnt" + +# "Delete" addon hook-script in aufs view +touch "/mnt/opt/openslx/uniontmp/.wh.addon-init" + 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 70a09924..a5dc9965 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 @@ -25,20 +25,29 @@ fi SLX_BASE_PATH=$(read_from_cmdline "slxbase") SLX_BASE_MNT="/opt/openslx/mnt" -SYS_TMP="/tmp" +SYS_TMP="/tmp/addons" +mkdir -p "$SYS_TMP" || { echo "Failed to create $SYS_TMP"; exit 1; } for ADDON in ${SLX_ADDONS}; do # download the addon from the given URL - ADDON_TARGET_PATH="${SYS_TMP}/$(basename $(echo ${ADDON})).sqfs" + ADDON_TARGET_PATH="${SYS_TMP}/$(basename "$ADDON").sqfs" download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}" # now mount it to $SLX_MNT/ - ADDON_MOUNT_POINT="${SLX_BASE_MNT}/$(basename $(echo ${ADDON}) | awk -F "." '{print $1}')" + 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." && 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 "Fail." && 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 +exit 0 + -- cgit v1.2.3-55-g7522 From ada35e7544bd25cb6beba9949910ed0476034152 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 16:30:44 +0200 Subject: [rootfs-stage32] Mount a 10G tmpfs to /tmp if no ID44 partition was found --- .../opt/openslx/scripts/systemd-setup_partitions | 136 +++++++++++---------- 1 file changed, 73 insertions(+), 63 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions index f162ec3a..bc5ce9c1 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_partitions @@ -17,38 +17,48 @@ # General formatter for the /tmp partition on a local harddisk diskfm () { -local target="$1" -local fs -local path -for fs in xfs ext3 ext2 ; do - unset available - case $(cat /proc/filesystems) in - *${fs}*) available=yes;; - *) modprobe "${fs}" && available=yes;; - esac - if [ -n "${available}" ]; then - unset found - if which "mkfs.$fs" ; then - found=yes - case "mkfs.$fs" in - mkfs.xfs) - fopt="-f" - mopt="-o noexec" - ;; - mkfs.ext2) - fopt="-Fq" - mopt="-o nocheck,noexec" - ;; - mkfs.reiserfs) - fopt="-f" - mopt="-o noexec" - ;; - esac - mkfs.$fs ${fopt} "${target}" - fi - [ -n "$found" ] && break - fi -done + local target="$1" + local fs + local path + for fs in xfs ext3 ext2 ; do + unset available + case $(cat /proc/filesystems) in + *${fs}*) available=yes;; + *) modprobe "${fs}" && available=yes;; + esac + if [ -n "${available}" ]; then + unset found + if which "mkfs.$fs" ; then + found=yes + case "mkfs.$fs" in + mkfs.xfs) + fopt="-f" + mopt="-o noexec" + ;; + mkfs.ext2) + fopt="-Fq" + mopt="-o nocheck,noexec" + ;; + mkfs.reiserfs) + fopt="-f" + mopt="-o noexec" + ;; + esac + mkfs.$fs ${fopt} "${target}" + fi + [ -n "$found" ] && break + fi + done +} + +function mount_temp () { + mkdir -p /tmptmp + mv /tmp/* /tmp/.* /tmptmp/ 2> /dev/null + mount $@ /tmp || return 1 + chmod a+rwxt /tmp + mv /tmptmp/* /tmptmp/.* /tmp/ + rmdir /tmptmp + return 0 } # Check for local harddisks and appropriate partitions @@ -66,46 +76,46 @@ for hdpartnr in $(sed -n -e "/ 82 /p" "/etc/disk.partition" | sed -e "s/[[:space swapon "$hdpartnr" done -# We use special non assigned partition type (id44) for harddisk scratch +# We use special non assigned partition type (id44) for harddisk scratch # space, thus no normal filesystem will be incidentally deleted or # corrupted for hdpartnr in $(sed -n -e "/ 44 /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - # check for supported filesystem and formatter - if diskfm "$hdpartnr"; then - # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready - echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab" - mkdir -p /tmptmp - mv /tmp/* /tmp/.* /tmptmp/ - mount "$hdpartnr" /tmp - chmod a+rwxt /tmp - mv /tmptmp/* /tmptmp/.* /tmp/ - rmdir /tmptmp - break - else - echo "formatting failed for some reason" - fi # Made this non-forking, systemd should handle it - 2013-05-28 + # check for supported filesystem and formatter + if diskfm "$hdpartnr"; then + # echo "$hdpartnr is mounted to /mnt/tmp at $(sysup)" >/tmp/tmpready + mount_temp "$hdpartnr" || continue + echo -e "$hdpartnr\t/tmp\t\tnoauto\t\tdefaults\t 0 0" >> "/etc/fstab" + break + else + echo "formatting failed for some reason" + fi # Made this non-forking, systemd should handle it - 2013-05-28 done # Put detected linux partitions (83) into /etc/fstab with "noauto", special # partition 45 (persistent scratch) to /var/scratch and 46 to /var/openslx for partid in 83 45 46 ; do - for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do - mkdir -p "/media/${hdpartnr#/dev/*}" - if [ "${partid}" -eq 83 ]; then - echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 45 ]; then - #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*} - #ln -sf /media/${hdpartnr#/dev/*} /var/scratch - echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" - elif [ "${partid}" -eq 46 ]; then - # Mount a home directory to (/mnt)/var/home - #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\ - #test -d /mnt/media/${hdpartnr#/dev/*}/home && \ - # ln -sf /media/${hdpartnr#/dev/*} /var/home - echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" - fi - done + for hdpartnr in $(sed -n -e "/ ${partid} /p" "/etc/disk.partition" | sed -e "s/[[:space:]].*//"); do + mkdir -p "/media/${hdpartnr#/dev/*}" + if [ "${partid}" -eq 83 ]; then + echo -e "$hdpartnr\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto,noexec\t 0 0" >> "/etc/fstab" + elif [ "${partid}" -eq 45 ]; then + #mount -t auto ${hdpartnr} /media/${hdpartnr#/dev/*} + #ln -sf /media/${hdpartnr#/dev/*} /var/scratch + echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" + elif [ "${partid}" -eq 46 ]; then + # Mount a home directory to (/mnt)/var/home + #mount -t auto ${hdpartnr} /mnt/media/${hdpartnr#/dev/*} \n\ + #test -d /mnt/media/${hdpartnr#/dev/*}/home && \ + # ln -sf /media/${hdpartnr#/dev/*} /var/home + echo -e "${hdpartnr}\t/media/${hdpartnr#/dev/*}\tauto\t\tnoauto\t\t 0 0" >> "/etc/fstab" + fi + done done mount -a +# Make huge tmpfs if nothing could be mounted for /tmp +if [ "$(mount | grep -c "on /tmp ")" = "0" ]; then + mount_temp -t tmpfs -o size=10G none +fi + -- cgit v1.2.3-55-g7522 From 26f2e448d55cba0b1823b4920cf311ed8892666f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 22 Aug 2013 10:47:54 +0200 Subject: [rootfs-stage31] Make MAC addresses lowercase, as udev fails to match a rule with uppercase letters in hex --- remote/rootfs/rootfs-stage31/data/bin/setup_network | 2 +- remote/rootfs/rootfs-stage31/data/init | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network index 8e070bdf..b504a92b 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_network +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network @@ -26,7 +26,7 @@ IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:] for LINE in $IP_OUT; do IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}') - IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[a-z]' '[A-Z]') + IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm echo "${IFACE} = ${IFMAC}" if [ "x$IFMAC" == "x$MAC" ]; then diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index db4ef484..838892e5 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -64,7 +64,7 @@ for opts in ${KCL}; do export NFSSERVER=${nfs%:/*} ;; BOOTIF=*) - export MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[a-z]' '[A-Z]' )" ;; + export MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network) esac done -- cgit v1.2.3-55-g7522 From 7199f8b6f00dbc904c92b6bfe1bad8d99c78c083 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 22 Aug 2013 12:11:21 +0200 Subject: [rootfs-stage31] Make download timeouts shorter, properly use drop_shell in the calling function/context, not in download() --- .../rootfs/rootfs-stage31/data/bin/setup_stage32 | 2 +- .../rootfs/rootfs-stage31/data/etc/functions.inc | 47 +++++++++++----------- 2 files changed, 24 insertions(+), 25 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index bc00b830..cf20fbf5 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -34,7 +34,7 @@ STAGE32_TARGET_PATH="/stage32.sqfs" STAGE32_MOUNT_POINT="/rorootfs" # try to download it -download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || return 1 +download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!" # try to mount it at STAGE32_MOUNT_POINT echo "Mounting stage 3.2 as SquashFS..." diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions.inc b/remote/rootfs/rootfs-stage31/data/etc/functions.inc index 362943ae..ce510aac 100644 --- a/remote/rootfs/rootfs-stage31/data/etc/functions.inc +++ b/remote/rootfs/rootfs-stage31/data/etc/functions.inc @@ -11,9 +11,9 @@ # drop_shell "This is your error message." # drop_shell() { - [ $# -gt 0 ] && echo $@ - echo "CTRL + D will continue booting." - setsid sh -c 'exec sh /dev/tty1 2>&1' + [ $# -gt 0 ] && echo $@ + echo "CTRL + D will continue booting." + setsid sh -c 'exec sh /dev/tty1 2>&1' } ######################################################################### @@ -28,7 +28,7 @@ read_from_cmdline(){ local OPTION="$1" local VALUE="" - + VALUE="$(grep -o -E "${OPTION}=\S+" /proc/cmdline | cut -c $((${#OPTION}+2))-)" if [ -z "$VALUE" ]; then echo "Error - '${OPTION}=' not found in command line, or empty" @@ -40,7 +40,7 @@ read_from_cmdline(){ ######################################################################### # -# Helper function to download given FILE_URL from servers in 'slxsrv' +# Helper function to download given FILE_URL from servers in 'slxsrv' # as given through the kernel command line. File will be saved under TARGET_PATH # # Usage: @@ -53,8 +53,8 @@ read_from_cmdline(){ # FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config" # download() { - [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1 - + [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguments, $# given." && return 1 + if [ -e "${FUTURE_ROOT}/opt/openslx/config" ]; then . "${FUTURE_ROOT}/opt/openslx/config" || echo "Error - could not source '${FUTURE_ROOT}/opt/openslx/config'" else @@ -62,31 +62,30 @@ download() { SLX_KCL_SERVERS="$(read_from_cmdline "slxsrv" | tr ',' ' ')" echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config" fi - - local FILE_URL="$1" - local TARGET_PATH="$2" - + + local FILE_URL="$1" + local TARGET_PATH="$2" + + # Shuffle server list local SERVERS=$(for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //') - - for TIMEOUT in 1 2 3 4 5; do + + for TIMEOUT in 1 1 4 4 10; do for SERVER in $SERVERS; do + rm -f "$TARGET_PATH" wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" RET=$? - if [ "x$RET" != "x0" ]; then + if [ "x$RET" != "x0" -o ! -e "$TARGET_PATH" ]; then echo "Error - downloading 'http://$SERVER/$FILE_URL' via wget failed. Exit Code: $RET" - echo "Trying again in $(($TIMEOUT * 500)) ms..." - [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..." - usleep $(($TIMEOUT * 500000)) + usleep 50000 # 50ms else - [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." + echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." return 0 fi done + echo "Trying again in $(($TIMEOUT * 250)) ms..." + usleep $(($TIMEOUT * 250000)) done - - # check if it actually worked - if [ ! -e $TARGET_PATH ]; then - echo "Error - $TARGET_PATH does not exists. Downloading '$FILE_URL' from '$SERVER_LIST' failed." - return 1 - fi + # Max retries reached, no success :-( + return 1 } + -- cgit v1.2.3-55-g7522 From de8d279742a0956578ffbcb612241466c0022f87 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 13:42:49 +0200 Subject: fix /etc/functions.inc sourcing --- remote/rootfs/rootfs-stage31/data/init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index 35e898b5..7e05084d 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -17,7 +17,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin export LD_LIBRARY_PATH=/usr/lib64 # import common functions -. /etc/functions +. /etc/functions.inc # mount the important standard directories mount -n -t tmpfs -o 'mode=755' run "/run" @@ -72,7 +72,7 @@ done [ "$DEBUG" -ge 1 ] && echo "0" >/proc/sys/kernel/printk || echo "4 4 1 7" >/proc/sys/kernel/printk # start plymouth if activated -if [ "x$SPLASH" == "x1" ]; then +if [ "x$SPLASH" == "x1" -a "$DEBUG" -lt 1 ]; then echo "Starting plymouth..." plymouthd && plymouth show-splash fi -- cgit v1.2.3-55-g7522 From bb8b9459f41bd7bf75795e2f3b7c2947a2757d98 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 13:49:45 +0200 Subject: fix /etc/functions.inc sourcing --- remote/rootfs/rootfs-stage31/data/bin/setup_stage32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index cf20fbf5..0d5c93c9 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -26,7 +26,7 @@ fi echo "Setting up stage 3.2 ..." # include /etc/functions -. /etc/functions +. /etc/functions.inc || drop_shell "Could not source /etc/functions.inc" # parse kernel command line to determine the URL of the stage3.2 SLX_BASE_PATH="$(read_from_cmdline "slxbase")" -- cgit v1.2.3-55-g7522 From e33cd88453edc3915f5c2736cfc773e18e61d1d5 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 13:55:45 +0200 Subject: minor --- remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig | 2 +- remote/rootfs/rootfs-stage31/data/bin/setup_stage32 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig index 6192137a..e1c148c9 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig +++ b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig @@ -3,7 +3,7 @@ echo "Configuring stage 3.2 ..." # include /etc/functions -. /etc/functions || drop_shell "Could not source /etc/functions." +#. /etc/functions || drop_shell "Could not source /etc/functions." # first a few variables CONFIG="${FUTURE_ROOT}/opt/openslx/config" diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index 0d5c93c9..90b0074b 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -26,7 +26,7 @@ fi echo "Setting up stage 3.2 ..." # include /etc/functions -. /etc/functions.inc || drop_shell "Could not source /etc/functions.inc" +#. /etc/functions.inc || drop_shell "Could not source /etc/functions.inc" # parse kernel command line to determine the URL of the stage3.2 SLX_BASE_PATH="$(read_from_cmdline "slxbase")" -- cgit v1.2.3-55-g7522 From 7d3abe5114a7779ca9806f2c80441af4bf5cdbcd Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 14:06:48 +0200 Subject: [rootfs-stage31] removed sourcing of /etc/functions.inc since it suffices to source it in the init. --- remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig | 3 --- remote/rootfs/rootfs-stage31/data/bin/setup_stage32 | 3 --- 2 files changed, 6 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig index e1c148c9..e7ec44be 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig +++ b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig @@ -2,9 +2,6 @@ echo "Configuring stage 3.2 ..." -# include /etc/functions -#. /etc/functions || drop_shell "Could not source /etc/functions." - # first a few variables CONFIG="${FUTURE_ROOT}/opt/openslx/config" diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 index 90b0074b..ba09b663 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 @@ -25,9 +25,6 @@ fi echo "Setting up stage 3.2 ..." -# include /etc/functions -#. /etc/functions.inc || drop_shell "Could not source /etc/functions.inc" - # parse kernel command line to determine the URL of the stage3.2 SLX_BASE_PATH="$(read_from_cmdline "slxbase")" STAGE32_TARGET_PATH="/stage32.sqfs" -- cgit v1.2.3-55-g7522 From b195ea20a53c5c7c5c5cbc19aefdba7e70588e51 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 15:27:59 +0200 Subject: [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. --- .../etc/systemd/system/setup-slx-addon@.service | 7 ++++ .../opt/openslx/scripts/systemd-setup_slx_addons | 49 ++++++++++++++++++---- 2 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 remote/rootfs/rootfs-stage32/data/etc/systemd/system/setup-slx-addon@.service (limited to 'remote') 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 -- cgit v1.2.3-55-g7522 From 92d8ecc99b197b2e0c0d1a2c5db3e60af7394d9b Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 15:35:40 +0200 Subject: [rootfs-stage32] unmount sqfs if the aufs'ing of the addon fails. --- .../data/opt/openslx/scripts/systemd-setup_slx_addons | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'remote') 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 e482cfb6..661beac4 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 @@ -70,7 +70,11 @@ if [ $# == 1 ]; then # now append it to / echo "Appending ${ADDON_MOUNT_POINT} to /" - mount -o "remount,append:${ADDON_MOUNT_POINT}=ro" / || { echo "Failed to append ${ADDON_MOUNT_POINT} to the aufs." && exit 1; } + if ! mount -o "remount,append:${ADDON_MOUNT_POINT}=ro" / ; then + echo "Failed to append ${ADDON_MOUNT_POINT} to the aufs. Cleaning up..." + umount -l ${ADDON_MOUNT_POINT} || echo "Could not unmount ${ADDON_MOUNT_POINT}!" + exit 1 + fi # Run post-hook if available if [ -x "$ADDON_MOUNT_POINT/addon-init" ]; then @@ -80,5 +84,6 @@ if [ $# == 1 ]; then fi [ $# -gt 1 ] && { echo "Error - $0 only takes no or one argument. $# given." && exit 1; } + exit 0 -- cgit v1.2.3-55-g7522 From faff0f925ea99662cefb649c81ea22bc346ec13c Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 16:32:36 +0200 Subject: [plymouth] moved plymouth stuff to /usr. Uses PREFIX from the config file --- remote/modules/plymouth/plymouth.build | 3 ++- remote/modules/plymouth/plymouth.conf | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'remote') diff --git a/remote/modules/plymouth/plymouth.build b/remote/modules/plymouth/plymouth.build index 1346f087..e46541f3 100644 --- a/remote/modules/plymouth/plymouth.build +++ b/remote/modules/plymouth/plymouth.build @@ -7,7 +7,8 @@ fetch_source() { build() { cd src/$VERSION pinfo "Running configure" - ./configure --enable-systemd-integration --disable-gtk --disable-static --prefix=""|| perror "failed." + + ./configure --enable-systemd-integration --disable-gtk --disable-static --prefix="$PREFIX"|| perror "failed." pinfo "Running make" make || perror "failed" pinfo "Running make install" diff --git a/remote/modules/plymouth/plymouth.conf b/remote/modules/plymouth/plymouth.conf index ec6f8571..d9acf6a3 100644 --- a/remote/modules/plymouth/plymouth.conf +++ b/remote/modules/plymouth/plymouth.conf @@ -1,14 +1,15 @@ VERSION=plymouth-0.8.6.1 URL=http://www.freedesktop.org/software/plymouth/releases/${VERSION}.tar.bz2 +PREFIX="/usr" REQUIRED_BINARIES=" plymouth plymouthd " REQUIRED_DIRECTORIES=" - /bin - /etc - /lib - /sbin - /var/lib - /var/spool + $PREFIX/bin + $PREFIX/etc + $PREFIX/lib + $PREFIX/sbin + $PREFIX/var/lib + $PREFIX/var/spool " -- cgit v1.2.3-55-g7522 From 5e09bdb4e204bed8635629b6812509bb03b7d59b Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 22 Aug 2013 16:34:05 +0200 Subject: [rootfs-stage31] start plymouth later --- remote/rootfs/rootfs-stage31/data/init | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index a75caab0..21c7a1bc 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -69,22 +69,24 @@ for opts in ${KCL}; do done # suppress kernel output if DEBUG is not set -[ "$DEBUG" -ge 1 ] && echo "0" >/proc/sys/kernel/printk || echo "4 4 1 7" >/proc/sys/kernel/printk +[ $DEBUG -ge 1 ] && echo "0" >/proc/sys/kernel/printk || echo "4 4 1 7" >/proc/sys/kernel/printk -# start plymouth if activated -if [ "x$SPLASH" == "x1" -a "$DEBUG" -lt 1 ]; then - echo "Starting plymouth..." - plymouthd && plymouth show-splash -fi - -[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: before network." +[ $DEBUG -ge 5 ] && drop_shell "Requested Debug Shell: before network." . "/bin/setup_network" || drop_shell "Error setting up network" -[ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring." +[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: after network/before configuring." . "/bin/activate_sysconfig" || drop_shell "Could not source /bin/activate_sysconfig" +[ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring." + +# start plymouth if activated +if [ "x$SPLASH" == "x1" -a "$DEBUG" -lt 1 ]; then + echo "Starting plymouth..." + plymouthd && plymouth show-splash +fi + [ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after configuration/before stage32." . "/bin/setup_stage32" || drop_shell "Problem setting up stage3.2" -- cgit v1.2.3-55-g7522