From 5ecba3429f3c5d75550137eb2c815ebb62dfdffb Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:03:34 +0200 Subject: Switch to using /etc/tmpfiles.d for creating files/dirs in /run Also added a sanity check after processing each module, which will abort if anything is placed in /run directly --- remote/rootfs/rootfs-stage32/rootfs-stage32.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index f9749740..99cb86f7 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -65,7 +65,9 @@ post_copy() { [ ! -e "$TARGET_BUILD_DIR/bin/mount" ] && ln -s /usr/bin/mount "$TARGET_BUILD_DIR/bin/mount" # make basic directory structure - mkdir -p "${TARGET_BUILD_DIR}"/{bin,dev,proc,lib,etc,mnt,sys,var/run,var/lock,var/log,run/lock,run/shm,opt/openslx/mnt} + mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,sys,var,opt/openslx/mnt} + ln -sf "/run/lock" "$TARGET_BUILD_DIR/var/lock" + ln -sf "/run" "$TARGET_BUILD_DIR/var/run" # make openslx log directory mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx -- cgit v1.2.3-55-g7522 From 8548d0869109a56f5afaeffb222dc688df1d3c60 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:06:39 +0200 Subject: Better make this relative... --- remote/rootfs/rootfs-stage32/rootfs-stage32.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index 99cb86f7..0b7398af 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -66,8 +66,8 @@ post_copy() { # make basic directory structure mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,sys,var,opt/openslx/mnt} - ln -sf "/run/lock" "$TARGET_BUILD_DIR/var/lock" - ln -sf "/run" "$TARGET_BUILD_DIR/var/run" + ln -sf "../run/lock" "$TARGET_BUILD_DIR/var/lock" + ln -sf "../run" "$TARGET_BUILD_DIR/var/run" # make openslx log directory mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx -- cgit v1.2.3-55-g7522 From c1bfa1880e6180466f7542cf1aa18d37b98c1644 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:09:09 +0200 Subject: FIXfgdksjfgkldjfg --- remote/rootfs/rootfs-stage32/rootfs-stage32.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index 0b7398af..dc53c237 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -65,7 +65,7 @@ post_copy() { [ ! -e "$TARGET_BUILD_DIR/bin/mount" ] && ln -s /usr/bin/mount "$TARGET_BUILD_DIR/bin/mount" # make basic directory structure - mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,sys,var,opt/openslx/mnt} + mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,run,sys,var,opt/openslx/mnt} ln -sf "../run/lock" "$TARGET_BUILD_DIR/var/lock" ln -sf "../run" "$TARGET_BUILD_DIR/var/run" -- cgit v1.2.3-55-g7522 From f6f820615a88a4943403cdcd5111a07bba6205df Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 20:21:44 +0200 Subject: Fix /run stuff for the 25th time.... --- remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf | 2 ++ remote/rootfs/rootfs-stage32/rootfs-stage32.build | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf b/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf new file mode 100644 index 00000000..ef610bdc --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/tmpfiles.d/run-lock.conf @@ -0,0 +1,2 @@ +D /run/lock 1777 root root + diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index dc53c237..02f238de 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -66,8 +66,7 @@ post_copy() { # make basic directory structure mkdir -p "$TARGET_BUILD_DIR"/{bin,dev,proc,lib,etc,mnt,run,sys,var,opt/openslx/mnt} - ln -sf "../run/lock" "$TARGET_BUILD_DIR/var/lock" - ln -sf "../run" "$TARGET_BUILD_DIR/var/run" + ln -s -n -f -t "$TARGET_BUILD_DIR/var" "../run/lock" "../run" # make openslx log directory mkdir -p "${TARGET_BUILD_DIR}"/var/log/openslx -- cgit v1.2.3-55-g7522 From f85fb3947b61e0def1ed69d945c408e56f1bbc3d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 20 Aug 2013 21:13:12 +0200 Subject: Fix typo in shebang --- .../rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue index c09162dc..8fbd5c8b 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/openslx-create_issue @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh # Set greeting and add information on booted system # Fixme (add version string and distro name) -- cgit v1.2.3-55-g7522 From c9c0dffa05c00428595b5ddebbeeb396418d3f65 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Aug 2013 13:43:56 +0200 Subject: [remote] Renamed functions to functions.inc; make setup-addons not fail if no addons are configured; try random server order when downloading --- remote/rootfs/rootfs-stage31/data/etc/functions | 90 --------------------- .../rootfs/rootfs-stage31/data/etc/functions.inc | 92 ++++++++++++++++++++++ remote/rootfs/rootfs-stage31/data/init | 4 +- .../opt/openslx/scripts/systemd-setup_slx_addons | 10 ++- 4 files changed, 100 insertions(+), 96 deletions(-) delete mode 100644 remote/rootfs/rootfs-stage31/data/etc/functions create mode 100644 remote/rootfs/rootfs-stage31/data/etc/functions.inc (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions b/remote/rootfs/rootfs-stage31/data/etc/functions deleted file mode 100644 index 37bb7d89..00000000 --- a/remote/rootfs/rootfs-stage31/data/etc/functions +++ /dev/null @@ -1,90 +0,0 @@ -######################################################################### -# -# COMMON HELPER FUNCTIONS -# - -######################################################################### -# -# Function to drop a debug shell with an error message. -# -# Usage: -# 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' -} - -######################################################################### -# -# Helper function to parse parameter named OPTION from the kernel command line (/proc/cmdline) -# -# Usage: -# read_from_cmdline OPTION -# -read_from_cmdline(){ - [ $# -ne 1 ] && echo "Error - 'read_from_cmdline' requires 1 argument, $# given." && exit 1 - - 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" - return 1 - else - echo "$VALUE" - fi -} - -######################################################################### -# -# 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: -# download FILE_URL TARGET_PATH -# -# Example: -# download "config" "/opt/openslx/config" -# -# Note: -# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config" -# -download() { - [ $# -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 - # read SLX_KCL_SERVERS from cmdline since we didn't get it from the config file. - 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" - - for TIMEOUT in 1 2 3 4 5; do - for SERVER in $SLX_CONFIG_SERVERS $SLX_KCL_SERVERS; do - wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" - RET=$? - if [ "x$RET" != "x0" ]; 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)) - else - [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." - return 0 - fi - done - 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 -} diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions.inc b/remote/rootfs/rootfs-stage31/data/etc/functions.inc new file mode 100644 index 00000000..362943ae --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/etc/functions.inc @@ -0,0 +1,92 @@ +######################################################################### +# +# COMMON HELPER FUNCTIONS +# + +######################################################################### +# +# Function to drop a debug shell with an error message. +# +# Usage: +# 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' +} + +######################################################################### +# +# Helper function to parse parameter named OPTION from the kernel command line (/proc/cmdline) +# +# Usage: +# read_from_cmdline OPTION +# +read_from_cmdline(){ + [ $# -ne 1 ] && echo "Error - 'read_from_cmdline' requires 1 argument, $# given." && exit 1 + + 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" + return 1 + else + echo "$VALUE" + fi +} + +######################################################################### +# +# 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: +# download FILE_URL TARGET_PATH +# +# Example: +# download "config" "/opt/openslx/config" +# +# Note: +# FILE_URL can have subpath, e.g. "ubuntu-13.04-x64/config" +# +download() { + [ $# -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 + # read SLX_KCL_SERVERS from cmdline since we didn't get it from the config file. + 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 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 SERVER in $SERVERS; do + wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" + RET=$? + if [ "x$RET" != "x0" ]; 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)) + else + [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." + return 0 + fi + done + 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 +} diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index 35e898b5..db4ef484 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" @@ -91,7 +91,7 @@ fi # copy files needed for stage3.2 to FUTURE_ROOT [ $DEBUG -ge 1 ] && echo "Copying busybox etc. to stage32..." -tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/etc/functions" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/" +tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" "/etc/functions.inc" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/" #echo 'blacklist pcspkr' >> /mnt/etc/modprobe.d/blacklist.conf # one last debug shell if activated 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 a3350424..70a09924 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 @@ -6,12 +6,14 @@ # # -. /opt/openslx/etc/functions +. /opt/openslx/config || { echo "Could not source config!"; exit 23; } +[ -z "${SLX_ADDONS}" ] && { echo "No addons configured. Nothing to do :-)."; exit 0; } + +. /opt/openslx/etc/functions.inc || { echo "functions.inc not found!"; exit 1337; } + export FUTURE_ROOT="/" # read openslx config -. /opt/openslx/config -[ -z "${SLX_ADDONS}" ] && { echo "SLX_ADDONS is not set in /opt/openslx/config." && exit 1; } 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 @@ -31,7 +33,7 @@ for ADDON in ${SLX_ADDONS}; do 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 $(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; } -- cgit v1.2.3-55-g7522 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/rootfs') 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/rootfs') 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/rootfs') 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/rootfs') 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