diff options
| author | Jonathan Bauer | 2013-08-15 16:20:44 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2013-08-15 16:20:44 +0200 |
| commit | 9d485e473e368ef50fe98cfdb11bee6095a53a40 (patch) | |
| tree | 1610123cf2b0c3de4a372b99ca8967a23c538d52 | |
| parent | update stage4 filter list (diff) | |
| download | tm-scripts-9d485e473e368ef50fe98cfdb11bee6095a53a40.tar.gz tm-scripts-9d485e473e368ef50fe98cfdb11bee6095a53a40.tar.xz tm-scripts-9d485e473e368ef50fe98cfdb11bee6095a53a40.zip | |
[stage31] move configuration of stage32 into /bin/activate_sysconfig.
| -rwxr-xr-x | remote/modules/debug/data/opt/openslx/bin/debug-report | 98 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig | 67 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig | 103 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/bin/setup_network (renamed from remote/rootfs/rootfs-stage31/data/bin/setup-network) | 0 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage31/data/init | 40 | ||||
| l--------- | remote/targets/vmware/vmplayer | 1 |
6 files changed, 117 insertions, 192 deletions
diff --git a/remote/modules/debug/data/opt/openslx/bin/debug-report b/remote/modules/debug/data/opt/openslx/bin/debug-report deleted file mode 100755 index 2c3aabe4..00000000 --- a/remote/modules/debug/data/opt/openslx/bin/debug-report +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -TOOLS=" - journalctl - systemctl - loginctl - lspci - lsusb - lsmod - mount -" - -URL="http://132.230.8.113/error_report.php" - -if [ "$UID" != "0" ]; then - echo "Debug Reports können nur von root versendet werden" >&2 - exit 1 -fi - -if ! curl -H "Expect:" -f -s -S --connect-timeout 5 "$URL" > /dev/null; then - echo "Kann den Debug-Report-Server in Freiburg nicht erreichen. :-(" >&2 - exit 1 -fi - -rm -rf /tmp/debug-report -mkdir -p /tmp/debug-report/{static,generated} - -if [ ! -d /tmp/debug-report ]; then - echo "FEHLER: Konnte /tmp/debug-report nicht erstellen!" >&2 - exit 1 -fi - -cd /tmp/debug-report - -cat > err-desc <<HEREEND - -# Bitte hier kurz eine passende Fehlerbeschreibung eingeben, anschließend -# Strg+O, ENTER, und Strg+X drücken. -HEREEND - -nano -w err-desc - -echo -n "Beginne mit dem Erstellen des Fehlerberichts..." - -. /opt/openslx/config - -echo "TIME INFORMATION:" > metadata -hwclock >> metadata -date >> metadata -for srv in 132.230.1.9 $SLX_NTP_SERVER 0.de.pool.ntp.org; do - ntpdate -u -q -p 2 -t 1 "$srv" >> metadata && break -done -echo -n "..." - -cp /opt/openslx/config /tmp/udhcpclog static/ 2> /dev/null -echo -n "." - -find /tmp/vmware* -name "*.log" -exec cp {} static/ \; 2> /dev/null -echo -n "." - -cp /var/log/Xorg.0.lo* static/ 2> /dev/null -cp /var/log/{auth.log,kdm.log,syslog,messages,user.log} static/ 2> /dev/null -cp /proc/cpuinfo static/ 2> /dev/null -echo -n "." - -for tool in $TOOLS; do - $tool > "generated/${tool}-out" 2> "generated/${tool}-err" - echo -n "." -done - -ip a > "generated/ip-a-out" 2> "generated/ip-a-err" -echo -n "." - -systemctl status > "generated/systemctl-status-out" 2> "generated/systemctl-status-err" -echo -n "." - -ps aux > "generated/ps-out" 2> "generated/ps-err" -echo -n "." - -echo "..fertig!" - -cd /tmp -rm -f error-report.tar.gz -echo -n "Packe Fehlerbericht ein..." -if ! tar czf error-report.tar.gz debug-report; then - echo "Fehler beim Packen des Berichts!" >&2 - exit 1 -fi -echo "....fertig!" - -echo -n "Lade Fehlerbericht hoch...." -if ! curl -H "Expect:" -f -s -S -F "file=@error-report.tar.gz;filename=report" "$URL" > /dev/null; then - echo "Fehler beim Hochladen des Fehlerberichts :-(" >&2 - exit 1 -fi - -echo "Fehlerbericht erfolgreich versendet!" - diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig deleted file mode 100755 index bfda70e1..00000000 --- a/remote/rootfs/rootfs-stage31/data/bin/activate-sysconfig +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# first a few variables -CONFIG="/mnt/opt/openslx/config" - -# 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 - -######################################################################### -# -# 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 -} - -######################################################################### -# -# -# This first part downloads the config containing environment variables -# -# - -[ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \ - && echo "Config already fetched." && exit 0 - -download "$URL" "$CONFIG-remote" || exit 1 - -echo "# Config fetched from $URL" >> "$CONFIG" -echo "#_RCONFIG_TAG" >> "$CONFIG" -cat "${CONFIG}-remote" >> "$CONFIG" - -######################################################################### -# -# -# This part downloads the config.tgz and unpacks it to $1 -# -# - -[ -e "$CONFIG.tgz" ] && echo "config.tgz already downloaded." && exit 0 -download "$URL.tgz" "$CONFIG.tgz" || exit 1 - -tar xf "$CONFIG.tgz" -C /mnt || { echo "Could not untar $CONFIG.tgz to /mnt"; exit 1; } -exit 0 diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig new file mode 100755 index 00000000..0d8d33c4 --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig @@ -0,0 +1,103 @@ +#!/bin/bash + +# first a few variables +CONFIG="/mnt/opt/openslx/config" + +# 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 + +######################################################################### +# +# 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 +} + +######################################################################### +# +# This function downloads the config containing environment variables +# +fetch_sysconfig() { + [ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \ + && echo "Config already fetched." && exit 0 + + download "$URL" "$CONFIG-remote" || exit 1 + + echo "# Config fetched from $URL" >> "$CONFIG" + echo "#_RCONFIG_TAG" >> "$CONFIG" + cat "${CONFIG}-remote" >> "$CONFIG" +} +######################################################################### +# +# 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 + + tar xf "$CONFIG.tgz" -C /mnt || { echo "Could not untar $CONFIG.tgz to /mnt"; exit 1; } + exit 0 +} + + +######################################################################### +# +# This function updates the downloaded config with the IP information +# 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." + + # write IP configuration to $CONFIG +cat >> "$CONFIG" <<HEREEND +# IP Config written in stage31 +SLX_PXE_CLIENT_IP='$CLIENTIP' +SLX_PXE_SERVER_IP='$SERVERIP' +SLX_PXE_GATEWAY='$GATEWAY' +SLX_PXE_DNS='$DNS_SERVER' +SLX_PXE_MAC='$BRIDGEMAC' +HEREEND + + # setup hardware clock + . /mnt/opt/openslx/config + if [ "x$SLX_BIOS_CLOCK" == "xlocal" ]; then + hwclock -s -l + elif [ "x$SLX_BIOS_CLOCK" == "xutc" ]; then + hwclock -s -u + fi +} + + +######################################################################### +# +# MAIN PART +# + +fetch_sysconfig || exit 1 +fetch_config_files || exit 1 +update_sysconfig || exit 1 diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup-network b/remote/rootfs/rootfs-stage31/data/bin/setup_network index 93ecd75f..93ecd75f 100755 --- a/remote/rootfs/rootfs-stage31/data/bin/setup-network +++ b/remote/rootfs/rootfs-stage31/data/bin/setup_network diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index db394c8d..8b971081 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -88,7 +88,7 @@ tar -cp "/bin" "/sbin" "/usr/bin" "/usr/sbin" | tar -xp -C "${FUTURE_ROOT}/opt/o [ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell (before network)." echo "Setup networking..." # Source script so the variables are still available to us -. "/bin/setup_network" || echo "Error setting up network" +. "/bin/setup_network" || drop_shell "Error setting up network" # mount rootfs if [ -n "$NFS" ]; then @@ -110,41 +110,27 @@ 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." +[ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after aufs'ing/before configuring." -# Download config if available -/bin/activate-sysconfig 2> /dev/null -if [ ! -e /mnt/opt/openslx/config ]; then - sleep 1 - /bin/activate-sysconfig -fi -if [ -e /mnt/opt/openslx/config ]; then - . /mnt/opt/openslx/config - if [ "x$SLX_BIOS_CLOCK" == "xlocal" ]; then - hwclock -s -l - elif [ "x$SLX_BIOS_CLOCK" == "xutc" ]; then - hwclock -s -u +# 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 -fi - -# create ip config -cat >> /mnt/opt/openslx/config <<HEREEND -# IP Config written in stage31 -SLX_PXE_CLIENT_IP='$CLIENTIP' -SLX_PXE_SERVER_IP='$SERVERIP' -SLX_PXE_GATEWAY='$GATEWAY' -SLX_PXE_DNS='$DNS_SERVER' -SLX_PXE_MAC='$BRIDGEMAC' -HEREEND +done +# one last debug shell if activated [ $DEBUG -ge 1 ] && drop_shell "Requested Debug Shell: before switch_root." +# tell plymouth about the immediate rootfs switch +[ "x$SPLASH" == "x1" -a "x$DEBUG" != "x1" ] && plymouth update-root-fs --new-root-dir=/mnt + +# unmount filesystems for mnt in proc sys run ; do umount -n "$mnt" done echo "Switching root...." unset BOOT_IMAGE initrd -[ "x$SPLASH" == "x1" -a "x$DEBUG" != "x1" ] && plymouth update-root-fs --new-root-dir=/mnt -# new style of pivoting (switch_root or run-init) exec /sbin/switch_root -c /dev/console /mnt /usr/lib/systemd/systemd diff --git a/remote/targets/vmware/vmplayer b/remote/targets/vmware/vmplayer new file mode 120000 index 00000000..9303aa6a --- /dev/null +++ b/remote/targets/vmware/vmplayer @@ -0,0 +1 @@ +../../modules/vmplayer
\ No newline at end of file |
