diff options
| author | Jonathan Bauer | 2014-06-25 17:22:51 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2014-06-25 17:22:51 +0200 |
| commit | c74e6a37f5714af44ba3e5a15e25b65ca4749259 (patch) | |
| tree | a30331a2ae8ce31424d867c75d76b8e1d1dd763b | |
| parent | [rootfs-stage32] ditro logo max tries and timeout (diff) | |
| parent | Merge branch 'master' of dnbd3:openslx-ng/tm-scripts (diff) | |
| download | tm-scripts-c74e6a37f5714af44ba3e5a15e25b65ca4749259.tar.gz tm-scripts-c74e6a37f5714af44ba3e5a15e25b65ca4749259.tar.xz tm-scripts-c74e6a37f5714af44ba3e5a15e25b65ca4749259.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
| -rw-r--r--[-rwxr-xr-x] | remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig | 4 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage31/data/inc/functions | 32 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage31/data/inc/parse_kcl | 56 | ||||
| -rw-r--r--[-rwxr-xr-x] | remote/rootfs/rootfs-stage31/data/inc/setup_network | 19 | ||||
| -rw-r--r--[-rwxr-xr-x] | remote/rootfs/rootfs-stage31/data/inc/setup_network_retry | 2 | ||||
| -rw-r--r--[-rwxr-xr-x] | remote/rootfs/rootfs-stage31/data/inc/setup_stage32 | 10 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/init | 34 |
7 files changed, 75 insertions, 82 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig index 02833b72..036e90ad 100755..100644 --- a/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig +++ b/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig @@ -5,10 +5,6 @@ echo "Configuring stage 3.2 ..." # first a few variables CONFIG="${FUTURE_ROOT}/opt/openslx/config" -# parse kernel command line to determine the base for the URLs -SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") -SLX_BASE_PATH=$(read_from_cmdline "slxbase") - ######################################################################### # # This function downloads the config containing environment variables diff --git a/remote/rootfs/rootfs-stage31/data/inc/functions b/remote/rootfs/rootfs-stage31/data/inc/functions index f07acc7d..5cc56dd7 100644 --- a/remote/rootfs/rootfs-stage31/data/inc/functions +++ b/remote/rootfs/rootfs-stage31/data/inc/functions @@ -22,28 +22,6 @@ drop_shell() { ######################################################################### # -# 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 # @@ -59,12 +37,8 @@ read_from_cmdline() { 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" + if [ -z "$SLX_KCL_SERVERS" ]; then + . "/opt/openslx/config" || echo "Error - could not source '/opt/openslx/config'" fi local FILE_URL="$1" @@ -73,7 +47,7 @@ download() { # 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 1 4 4 10; do + for TIMEOUT in 1 1 2; do for SERVER in $SERVERS; do rm -f "$TARGET_PATH" wget -T 5 -q -O "$TARGET_PATH" "http://${SERVER}/${FILE_URL}" diff --git a/remote/rootfs/rootfs-stage31/data/inc/parse_kcl b/remote/rootfs/rootfs-stage31/data/inc/parse_kcl new file mode 100644 index 00000000..485e5f87 --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/inc/parse_kcl @@ -0,0 +1,56 @@ +#!/bin/ash + +getip () { + echo "${IPINFO}" | awk -F ':' "{print \$$1}" +} +parse_ip () { + local IPINFO=$1 + CLIENTIP="$(getip 1)" + SERVERIP="$(getip 2)" + GATEWAY="$(getip 3)" + SUBNET_MASK="$(getip 4)" + BROADCAST_ADDRESS="$(ipcalc -s -b "$CLIENTIP" "$SUBNET_MASK" | sed s/.*=//)" + [ -z "$BROADCAST_ADDRESS" ] && BROADCAST_ADDRESS="255.255.255.255" + # we might have an idea of the dns server via preboot + DNS_SERVER="$(getip 5)" +} + +# read kernel command line +DEBUG=0 +SPLASH=0 +read KCL < "/proc/cmdline" +for opts in ${KCL}; do + case "${opts}" in + debug=*) + DEBUG=${opts#debug=} ;; + ip=*) + # process IP info + parse_ip ${opts#ip=} ;; + nfs=*) # TODO: Still working? Still needed? Also see related code in setup_stage32 + NFS=${opts#nfs=} + NFSPATH=${NFS#*:} + NFSSERVER=${NFS%:/*} + ;; + BOOTIF=*) + MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network) + slxsrv=*) + SLX_KCL_SERVERS=$( echo "${opts#slxsrv=}" | tr ',' " " ) ;; + slxbase=*) + SLX_BASE_PATH=${opts#slxbase=} ;; + splash) + [ -e "/etc/splash.ppm" ] && SPLASH=1 ;; + nvidia) + GFX=nvidia ;; + ati|amd) + GFX=amd ;; + esac +done + +# If slxsrv was not given on command line, just use the PXE server's address +[ -z "$SLX_KCL_SERVERS" ] && [ -n "$SERVERIP" ] && SLX_KCL_SERVERS="$SERVERIP" +# Now save to config file +echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config" +echo "SLX_BASE_PATH='$SLX_BASE_PATH'" >> "${FUTURE_ROOT}/opt/openslx/config" + +true + diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_network b/remote/rootfs/rootfs-stage31/data/inc/setup_network index 2ba02f84..13c52289 100755..100644 --- a/remote/rootfs/rootfs-stage31/data/inc/setup_network +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network @@ -25,6 +25,10 @@ mkdir -p "${FUTURE_ROOT}/etc/udev/rules.d" #IP_OUT=$(ip a | sed -r ':a;N;$!ba;s/: ([a-z0-9]+): /####\1####/g;s/ether ([a-f0-9:]+) /####\1####/g'| grep -E -o '####[^ ]+####' | sed 's/#//g' | grep -B 1 ':') IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]+): .*?/ether ([0-9a-fA-Z:]+) .*$#\1==\2#') +if ! echo "$IP_OUT" | grep -q -- "$MAC"; then + drop_shell "Boot interface not found in interface list. NIC driver missing?" +fi + 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]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm @@ -44,20 +48,9 @@ for LINE in $IP_OUT; do # analyze ip information from the kernel command line and put parts # of it into several variables - if [ -n "$IPINFO" ] ; then - getip () { - echo "${IPINFO}" | awk -F ':' "{print \$$1}" - } - CLIENTIP="$(getip 1)" - SERVERIP="$(getip 2)" - GATEWAY="$(getip 3)" - SUBNET_MASK="$(getip 4)" - BROADCAST_ADDRESS="$(ipcalc -s -b "$CLIENTIP" "$SUBNET_MASK" | sed s/.*=//)" - [ -z "$BROADCAST_ADDRESS" ] && BROADCAST_ADDRESS="255.255.255.255" - # we might have an idea of the dns server via preboot - DNS_SERVER="$(getip 5)" + if [ -n "$CLIENTIP" ] ; then # set static ip address - [ -n "$CLIENTIP" ] && ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" + ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" ip link set dev "$BRIDGE" up [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE" else diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry b/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry index 9239d0d7..0578d9b2 100755..100644 --- a/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry @@ -27,7 +27,7 @@ for i in 1 2 3 4 5 6 7 8; do fi done -[ $RET -gt 0 ] && echo "Something is really broken.. Please check your network cable and reset your computer." +[ $RET -gt 0 ] && drop_shell "Something is really broken.. Please check your network cable and reset your computer." # create correct return value [ $RET -eq 0 ] diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 b/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 index b96566ce..5ec5a69d 100755..100644 --- a/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 @@ -25,14 +25,15 @@ fi echo "Setting up stage 3.2 ..." -# parse kernel command line to determine the URL of the stage3.2 -SLX_BASE_PATH="$(read_from_cmdline "slxbase")" STAGE32_TARGET_PATH="/stage32.sqfs" STAGE32_MOUNT_POINT="/rorootfs" # try to download it download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!" +# "Delete" addon hook-script in aufs view +touch "${FUTURE_ROOT}/.wh.addon-init" + # try to mount it at STAGE32_MOUNT_POINT echo "Mounting stage 3.2 as SquashFS..." busybox mount -n -t squashfs "$STAGE32_TARGET_PATH" "$STAGE32_MOUNT_POINT" || drop_shell "Problem mounting Squashfs." @@ -40,7 +41,7 @@ busybox mount -n -t squashfs "$STAGE32_TARGET_PATH" "$STAGE32_MOUNT_POINT" || dr echo "Building aufs ..." busybox mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || drop_shell "Problem building aufs." mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp -busybox mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." +#busybox mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." # Move needed? FUTURE_ROOT="/mnt" # Move network stuff @@ -65,6 +66,3 @@ if [ -n "$SLX_BENCHMARK_VM" ]; then # a numeric value for the index in vmchooser fi -# "Delete" addon hook-script in aufs view -touch "/mnt/opt/openslx/uniontmp/.wh.addon-init" - diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index fdf174ed..1cfc9a98 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -26,7 +26,7 @@ bench_event "KERNEL" "Kernel initialized" # NOTE: busybox mount is only available through the busybox binary, # the link had to be dropped, to prevent bugs in the stage32. -busybox mount -n -t devtmpfs -o 'rw,relatime,nosuid,noexec,mode=0755' initramfsdevs /dev +busybox mount -n -t devtmpfs -o 'rw,relatime,nosuid,noexec,mode=0755' initramfsdevs /dev busybox mount -n -t tmpfs -o 'mode=755' run "/run" # preparations for mounting stage3.2 @@ -36,39 +36,15 @@ busybox mount -n -t tmpfs -o 'mode=755' none "$FUTURE_ROOT" mkdir -p "$FUTURE_ROOT/opt/openslx" -# read kernel command line -DEBUG=0 -SPLASH=0 -read KCL < "/proc/cmdline" -for opts in ${KCL}; do - case "${opts}" in - debug=*) - DEBUG=${opts#debug=} ;; - ip=*) - # process IP info - IPINFO=${opts#ip=} ;; - nfs=*) - NFS=${opts#nfs=} - NFSPATH=${NFS#*:} - NFSSERVER=${NFS%:/*} - ;; - BOOTIF=*) - MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network) - splash) - [ -e "/etc/splash.ppm" ] && SPLASH=1 ;; - nvidia) - GFX=nvidia ;; - ati|amd) - GFX=amd ;; - esac -done +# Get all variables we care about from the KCL +. /inc/parse_kcl # NOTE: this is only relevant when using the distro's kernel # load kernel modules as given in /etc/modules modprobe -a -b $(cat /etc/modules) 2>/dev/null +# Load drm gfx drivers, if successful, check if splash screen should be shown, and do so . "/inc/drm.functions" - if [ "$SPLASH" -eq 1 ]; then if setup_gfx; then echo "1 1 0 1" > /proc/sys/kernel/printk @@ -81,7 +57,7 @@ else setup_gfx fi -# suppress kernel output if neither DEBUG nor SPLASH is set +# suppress kernel output if DEBUG is set and no splash screen is requested if [ $SPLASH -eq 0 ]; then [ $DEBUG -ge 1 ] && echo "4 4 1 7" > /proc/sys/kernel/printk || echo "1 1 0 1" >/proc/sys/kernel/printk fi |
