From cf1678292b695d2e2fd5ed194cee4e6135660fd3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 15 Aug 2013 17:53:52 +0200 Subject: merge --- remote/rootfs/rootfs-stage31/data/etc/functions | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 remote/rootfs/rootfs-stage31/data/etc/functions (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions b/remote/rootfs/rootfs-stage31/data/etc/functions new file mode 100644 index 00000000..ff1276a5 --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/etc/functions @@ -0,0 +1,44 @@ +######################################################################### +# +# 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 download given FILE_URL under TARGET_PATH +# +# Usage: +# download $FILE_URL $TARGET_PATH +# +download() { + [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguements, $# given." \ + && exit 1 + + local FILE_URL="$1" + local TARGET_PATH="$2" + + wget -T 5 -q -O "$TARGET_PATH" "$FILE_URL" + RET=$? + if [ "x$RET" != "x0" ]; then + echo "Error - downloading '$FILE_URL' via wget failed. Exit Code: $RET" + exit 1 + else + echo "Successfully downloaded '$FILE_URL'." + fi + + return 0 +} + -- cgit v1.2.3-55-g7522 From 6fa1764201644b0dec129d005381ee498962e605 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 19 Aug 2013 16:24:23 +0200 Subject: [rootfs-stage31] changed the way stage3.1 gets the config, config.tgz and stage32.sqfs. Now its given in the kernel cmdline as 'slxsrv' a list of server ips and 'slxbase' a subdirectory of these servers where the config stuff roams. Example: slxsrv='132.230.4.1' and slxbase='u13' would make the scripts download '132.230.4.1/u13/config' and so on. PLEASE ADAPT YOUR CONFIGS BEFORE TRYING THIS OUT --- .../rootfs-stage31/data/bin/activate_sysconfig | 66 ++++++-------------- .../rootfs/rootfs-stage31/data/bin/setup_network | 2 + .../rootfs/rootfs-stage31/data/bin/setup_stage32 | 47 ++++++++++++++ remote/rootfs/rootfs-stage31/data/etc/functions | 71 +++++++++++++++++----- remote/rootfs/rootfs-stage31/data/init | 55 +++++------------ 5 files changed, 140 insertions(+), 101 deletions(-) create mode 100755 remote/rootfs/rootfs-stage31/data/bin/setup_stage32 (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig index 0d8d33c4..9c21565a 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig +++ b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig @@ -1,40 +1,15 @@ #!/bin/bash -# first a few variables -CONFIG="/mnt/opt/openslx/config" +echo "Configuring stage 3.2 ..." -# parse kernel command line to determine the URL -URL="$(grep -o -E "slxconfig=\S+" /proc/cmdline | cut -c 11-)" -if [ -z "$URL" ]; then - echo "Error - 'slxconfig=' not found in command line, or empty" - exit 1 -fi +# include /etc/functions +. /etc/functions || drop_shell "Could not source /etc/functions." -######################################################################### -# -# Helper function to download given FILE_URL under TARGET_PATH -# -# Usage: -# download $FILE_URL $TARGET_PATH -# -download() { - [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguements, $# given." \ - && exit 1 - - local FILE_URL="$1" - local TARGET_PATH="$2" - - wget -T 5 -q -O "$TARGET_PATH" "$FILE_URL" - RET=$? - if [ "x$RET" != "x0" ]; then - echo "Error - downloading '$FILE_URL' via wget failed. Exit Code: $RET" - exit 1 - else - echo "Successfully downloaded '$FILE_URL'." - fi - - return 0 -} +# first a few variables +CONFIG="${FUTURE_ROOT}/opt/openslx/config" + +# parse kernel command line to determine the base for the URLs +SLX_BASE=$(read_from_cmdline "slxbase") ######################################################################### # @@ -42,9 +17,9 @@ download() { # fetch_sysconfig() { [ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \ - && echo "Config already fetched." && exit 0 + && echo "Config already fetched." && return 0 - download "$URL" "$CONFIG-remote" || exit 1 + download "${SLX_BASE}/config" "${CONFIG}-remote" || return 1 echo "# Config fetched from $URL" >> "$CONFIG" echo "#_RCONFIG_TAG" >> "$CONFIG" @@ -55,11 +30,9 @@ fetch_sysconfig() { # This function downloads the config.tgz and unpacks it to $TARGET_PATH # fetch_config_files() { - [ -e "$CONFIG.tgz" ] && echo "config.tgz already downloaded." && exit 0 - download "$URL.tgz" "$CONFIG.tgz" || exit 1 + [ -e "${CONFIG}.tgz" ] && echo "config.tgz already downloaded." && exit 0 - tar xf "$CONFIG.tgz" -C /mnt || { echo "Could not untar $CONFIG.tgz to /mnt"; exit 1; } - exit 0 + download "${SLX_BASE}/config.tgz" "${CONFIG}.tgz" || return 1 } @@ -69,9 +42,8 @@ fetch_config_files() { # received from /bin/setup_network update_sysconfig() { # sanity checks - [ ! -e "$CONFIG" ] && { echo "Cannot update $CONFIG: file does not exist!"; exit 1; } - [ -z "$CLIENTIP" -o -z "$SERVERIP" -o -z "$BRIDGEMAC" -o -z "$GATEWAY" -o -z "$DNS_SERVER" ] \ - && echo "Something seems wrong with the IP information read from /bin/setup_network ... going on." + [ ! -e "${CONFIG}" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } + [ ! -e "${CONFIG}.tgz" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } # write IP configuration to $CONFIG cat >> "$CONFIG" </dev/tty1 2>&1' -} - # set PATH correctly export PATH=/bin:/sbin:/usr/bin:/usr/sbin export LD_LIBRARY_PATH=/usr/lib64 +# import common functions +. /etc/functions + # mount the important standard directories mount -n -t tmpfs -o 'mode=755' run "/run" [ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc @@ -81,44 +77,21 @@ if [ "x$SPLASH" == "x1" -a "x$DEBUG" != "x1" ]; then plymouthd && plymouth show-splash fi +[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: before network." -echo "Copying busybox etc. to stage32..." -tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" | tar -xp -C "${FUTURE_ROOT}/opt/openslx/" +. "/bin/setup_network" || drop_shell "Error setting up network" -[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell (before network)." +[ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring." -echo "Setup networking..." # Source script so the variables are still available to us -. "/bin/setup_network" || drop_shell "Error setting up network" +. "/bin/activate_sysconfig" || drop_shell "Could not source /bin/activate_sysconfig" -# mount rootfs -if [ -n "$NFS" ]; then - # mount stage32 per NFS if activated - echo "Mounting stage 3.2 as NFS..." - mount -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs || drop_shell "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}." -else - # or per squashfs else - echo "Mounting stage 3.2 as SquashFS..." - mount -t squashfs /mnt/*.sqfs /rorootfs || drop_shell "Problem mounting Squashfs." -fi - -[ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: squashfs/nfs mounted, before aufs." - -echo "Building aufs..." -#mount -t overlayfs -o lowerdir=/rorootfs,upperdir=/dev/shm/uniontmp overlayfs /mnt -mount -n -t aufs -o "br:${FUTURE_ROOT}:/rorootfs=ro" none /mnt || drop_shell "Problem building aufs." -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" - -[ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after aufs'ing/before configuring." - -# Download config. Try 5 times with increasing sleeps. -for TIMEOUT in 1 2 3 4 5; do - if [ ! -e /mnt/opt/openslx/config ]; then - /bin/activate_sysconfig - sleep $TIMEOUT - fi -done +[ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after configuration/before stage32." + +. "/bin/setup_stage32" || drop_shell "Problem setting up stage3.2" + +# 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/" # one last debug shell if activated [ $DEBUG -ge 1 ] && drop_shell "Requested Debug Shell: before switch_root." -- cgit v1.2.3-55-g7522 From cf966cfde42cf7d4c64635e567c398b953213adf Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 19 Aug 2013 16:32:12 +0200 Subject: [rootfs-stage31] prioritize servers from the config file over those in kernel cmdline --- remote/rootfs/rootfs-stage31/data/etc/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions b/remote/rootfs/rootfs-stage31/data/etc/functions index 5c5ba56c..1918c82a 100644 --- a/remote/rootfs/rootfs-stage31/data/etc/functions +++ b/remote/rootfs/rootfs-stage31/data/etc/functions @@ -64,7 +64,7 @@ download() { local TARGET_PATH="$2" for TIMEOUT in 1 2 3 4 5; do - for SERVER in $SLX_BASE_SERVERS $SLX_SERVERS; do + for SERVER in $SLX_SERVERS $SLX_BASE_SERVERS; do wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" RET=$? if [ "x$RET" != "x0" ]; then -- cgit v1.2.3-55-g7522 From 3a535ef15a6386c3070c52e702a1e8503a47deff Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 19 Aug 2013 16:49:55 +0200 Subject: [rootfs-stage31] renamed a few variables. For the servers to download config stuff from, use SLX_CONFIG_SERVER in your config file --- remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig | 11 +++++++---- remote/rootfs/rootfs-stage31/data/bin/setup_stage32 | 4 ++-- remote/rootfs/rootfs-stage31/data/etc/functions | 6 ++++-- 3 files changed, 13 insertions(+), 8 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 9c21565a..1c942d7a 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig +++ b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig @@ -9,7 +9,8 @@ echo "Configuring stage 3.2 ..." CONFIG="${FUTURE_ROOT}/opt/openslx/config" # parse kernel command line to determine the base for the URLs -SLX_BASE=$(read_from_cmdline "slxbase") +SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") +SLX_BASE_PATH=$(read_from_cmdline "slxbase") ######################################################################### # @@ -19,7 +20,7 @@ fetch_sysconfig() { [ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \ && echo "Config already fetched." && return 0 - download "${SLX_BASE}/config" "${CONFIG}-remote" || return 1 + download "${SLX_BASE_PATH}/config" "${CONFIG}-remote" || return 1 echo "# Config fetched from $URL" >> "$CONFIG" echo "#_RCONFIG_TAG" >> "$CONFIG" @@ -32,7 +33,7 @@ fetch_sysconfig() { fetch_config_files() { [ -e "${CONFIG}.tgz" ] && echo "config.tgz already downloaded." && exit 0 - download "${SLX_BASE}/config.tgz" "${CONFIG}.tgz" || return 1 + download "${SLX_BASE_PATH}/config.tgz" "${CONFIG}.tgz" || return 1 } @@ -45,7 +46,7 @@ update_sysconfig() { [ ! -e "${CONFIG}" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } [ ! -e "${CONFIG}.tgz" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } - # write IP configuration to $CONFIG + # write IP and SLX_SERVER configuration to $CONFIG cat >> "$CONFIG" <> "${FUTURE_ROOT}/opt/openslx/config" fi local FILE_URL="$1" @@ -75,7 +76,7 @@ download() { [ $TIMEOUT -eq 5 ] && drop_shell "Max timeouts reached. Dropping shell..." usleep $(($TIMEOUT * 500000)) else - [ $DEBUG -ge 1 ] && echo "Successfully downloaded '$FILE_URL'." + [ "x$DEBUG" != "x" ] && echo "Successfully downloaded 'http://${SERVER}/$FILE_URL'." return 0 fi done 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 b6f04d55..a3350424 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,27 +6,32 @@ # # -# 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" +. /opt/openslx/etc/functions +export FUTURE_ROOT="/" # 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; } +[ -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 + SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") + fi +fi + +# read base slx servers from cmdline +SLX_BASE_PATH=$(read_from_cmdline "slxbase") SLX_BASE_MNT="/opt/openslx/mnt" SYS_TMP="/tmp" -for ADDON in ${SLX_ADDONS_LIST}; do +for ADDON in ${SLX_ADDONS}; do # download the addon from the given URL - local 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; } + ADDON_TARGET_PATH="${SYS_TMP}/$(basename $(echo ${ADDON})).sqfs" + download "${SLX_BASE_PATH}/${ADDON}.sqfs" "${ADDON_TARGET_PATH}" # now mount it to $SLX_MNT/ - local 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 4b1854b09632d8c96cba989ad1f955641b20bf92 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 19 Aug 2013 18:35:19 +0200 Subject: fix pcspkr already registered. Uncomment to make it work ;) --- remote/rootfs/rootfs-stage31/data/init | 1 + 1 file changed, 1 insertion(+) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index f0db8730..aba3ac16 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -92,6 +92,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/" +#echo 'blacklist pcspkr' >> /mnt/etc/modprobe.d/blacklist.conf # one last debug shell if activated [ $DEBUG -ge 1 ] && drop_shell "Requested Debug Shell: before switch_root." -- cgit v1.2.3-55-g7522 From 5050eebd553033f466f8e3e69960e04e9d78bef1 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 20 Aug 2013 13:55:11 +0200 Subject: [rootfs-stage31] activate plymouth with 'splash' in the kcl. (Removed the DEBUG check) --- remote/rootfs/rootfs-stage31/data/init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'remote') diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index aba3ac16..35e898b5 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -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" -a "x$DEBUG" != "x1" ]; then +if [ "x$SPLASH" == "x1" ]; then echo "Starting plymouth..." plymouthd && plymouth show-splash fi -- cgit v1.2.3-55-g7522