summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2014-08-29 16:11:00 +0200
committerJonathan Bauer2014-08-29 16:11:00 +0200
commitc20f215e0b8b93d7c30276dae92768bd15f5b8e4 (patch)
treed3d995f2c4dcfbcd834a9c57b8b45402875bf81c
parent[pvs2-fr] fix startup sessionscript for pvs (diff)
downloadtm-scripts-c20f215e0b8b93d7c30276dae92768bd15f5b8e4.tar.gz
tm-scripts-c20f215e0b8b93d7c30276dae92768bd15f5b8e4.tar.xz
tm-scripts-c20f215e0b8b93d7c30276dae92768bd15f5b8e4.zip
[rfs-s31] new setup_stage4 script. Not beeing used currently
WIP
-rw-r--r--remote/rootfs/rootfs-stage31/data/inc/setup_stage469
1 files changed, 69 insertions, 0 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_stage4 b/remote/rootfs/rootfs-stage31/data/inc/setup_stage4
new file mode 100644
index 00000000..585627c2
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/inc/setup_stage4
@@ -0,0 +1,69 @@
+#!/bin/ash
+
+[ -z "${SLX_STAGE4}" ] && { echo "SLX_STAGE4 is not set in /opt/openslx/config." && exit 1; }
+
+MOUNTPOINT="/rorootfs/"
+mkdir -p "$MOUNTPOINT"
+
+
+# first load module
+insmod /lib/modules/dnbd3/dnbd3.ko
+
+# dnbd3 it is
+if [ -z "${SLX_DNBD3_SERVERS}${SLX_DNBD3_PRIO_SERVERS}" ]; then
+ slxlog --echo "mount-stage4" "dnbd3 stage4 configured, but SLX_DNBD3(_PRIO)_SERVERS empty or not set in /opt/openslx/config."
+ exit 1
+fi
+# Determine revision
+if [ -z "$SLX_STAGE4_RID" ] || echo "$SLX_STAGE4_RID" | grep -v -q -E "^[0-9]+$"; then
+ SLX_STAGE4_RID="0"
+fi
+# Randomize list
+SERVERS=$(for SERVER in $SLX_DNBD3_SERVERS; do echo "$RANDOM $SERVER"; done | sort -u | sed -r 's/^[0-9]+ //')
+IMAGE=$(echo $SLX_STAGE4 | awk '{printf $2}')
+[ -e /var/run/dnbd3.socket ] || sleep 2 # Ugly, service should only start when dnbd3 daemon is up and running
+RET=1337
+for SRV in $SLX_DNBD3_PRIO_SERVERS $SERVERS; do
+ echo "Requesting $IMAGE from $SRV"
+ dnbd3=$(/opt/openslx/bin/dnbd3-client -h "$SRV" -i "$IMAGE" -r "$SLX_STAGE4_RID" -d /dev/dnbd0)
+ RET=$?
+ [ "$RET" -eq "0" ] && break
+ echo "... didn't work ($RET)"
+ sleep 1
+done
+if [ "$RET" -ne "0" ]; then
+ drop_shell "Omg"
+ slxlog --echo "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE : $SLX_STAGE4_RID) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)"
+ exit $RET
+fi
+echo "Mounting /dev/dnbd0 to $MOUNTPOINT"
+if ! busybox mount -t squashfs -o ro /dev/dnbd0 "$MOUNTPOINT"; then
+ slxlog --echo "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)"
+ exit 1
+fi
+
+busybox mount -n -t aufs -o "br:${FUTURE_ROOT}:${MOUNTPOINT}=ro" none /mnt || drop_shell "Problem building aufs."
+mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp
+FUTURE_ROOT="/mnt"
+
+cp /etc/hostname /etc/hosts "${FUTURE_ROOT}/etc/"
+cp /etc/resolv.conf "${FUTURE_ROOT}/opt/openslx/"
+[ -s "/run/config" ] && cat "/run/config" >> "${FUTURE_ROOT}/opt/openslx/config"
+
+# if booting with splash, suppress kernel output in stage32
+if [ $SPLASH -eq 1 ]; then
+ if grep -q -E "^ *kernel.printk" "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"; then
+ sed -i 's/^ *kernel\.printk.*/kernel\.printk = 1 1 0 1/g' "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"
+ else
+ echo "kernel.printk = 1 1 0 1" >> "${FUTURE_ROOT}/usr/lib/sysctl.d/50-default.conf"
+ fi
+fi
+
+# Kinda specific for virtualization environment: Autologin and run VM for benchmarks
+if [ -n "$SLX_BENCHMARK_VM" ]; then
+ # Enable KDM autologin for demo user
+ sed -i 's/^AutoLoginUser=.*//;s/^AutoLoginEnable=.*/AutoLoginEnable=true\nAutoLoginUser=demo/' "${FUTURE_ROOT}/etc/kde4/kdm/kdmrc"
+ # Running the VM automatically has to be taken care of by run-virt and vmchooser. SLX_BENCHMARK_VM should contain
+ # a numeric value for the index in vmchooser
+fi
+