From 2886b95ce44f678ce6bea5bf9b6dead40643059f Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 16 Jan 2014 14:57:38 +0100 Subject: [stage4] renamed nfs-mount to mount-stage4. Added new 'stage4.target'. --- .../data/etc/systemd/system/mount-stage4.service | 10 ++++ .../data/etc/systemd/system/nfs-mount.service | 11 +--- .../data/etc/systemd/system/stage4.target | 3 + .../data/opt/openslx/scripts/systemd-mount_export | 60 -------------------- .../data/opt/openslx/scripts/systemd-mount_stage4 | 64 ++++++++++++++++++++++ .../system/basic.target.wants/mount-stage4.service | 1 + .../system/basic.target.wants/nfs-mount.service | 1 - 7 files changed, 79 insertions(+), 71 deletions(-) create mode 100644 remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service mode change 100644 => 120000 remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service create mode 100644 remote/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target delete mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export create mode 100755 remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4 create mode 120000 server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/mount-stage4.service delete mode 120000 server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/nfs-mount.service diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service new file mode 100644 index 00000000..15725f8f --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/mount-stage4.service @@ -0,0 +1,10 @@ +[Unit] +Description=Mount Openslx Stage 4 +DefaultDependencies=no +Wants=setup-dnbd3.service +After=setup-dnbd3.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/opt/openslx/scripts/systemd-mount_stage4 diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service deleted file mode 100644 index 3deb3def..00000000 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Mount NFS Share [TEST] -DefaultDependencies=no -Wants=setup-dnbd3.service -After=setup-dnbd3.service - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/opt/openslx/scripts/systemd-mount_export diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service new file mode 120000 index 00000000..c1792e42 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service @@ -0,0 +1 @@ +mount-stage4.service \ No newline at end of file diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target new file mode 100644 index 00000000..465a324c --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/stage4.target @@ -0,0 +1,3 @@ +[Unit] + +Description=OpenSLX Stage 4 diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export deleted file mode 100755 index 4c8597a9..00000000 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# Needs full bash - -. /opt/openslx/config - -[ -z "${SLX_STAGE4}" ] && { echo "SLX_STAGE4 is not set in /opt/openslx/config." && exit 1; } - -MOUNTPOINT="/opt/openslx/mnt/stage4" -mkdir -p "$MOUNTPOINT" - -if [[ "$SLX_STAGE4" == dnbd3* ]]; then - # 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=$(dnbd3-client -h "$SRV" -i "$IMAGE" -r "$SLX_STAGE4_RID") - RET=$? - [ "$RET" -eq "0" ] && break - echo "... didn't work ($RET)" - sleep 1 - done - if [ "$RET" -ne "0" ]; then - slxlog --echo "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE : $SLX_STAGE4_RID) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)" - exit $RET - fi - echo "Mounting $dnbd3 to $MOUNTPOINT" - if ! mount -t squashfs -o ro "$dnbd3" "$MOUNTPOINT"; then - slxlog --echo "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)" - exit 1 - fi -else - # Try nfs - echo "Mounting ${SLX_STAGE4} to $MOUNTPOINT" - if ! mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4" "$MOUNTPOINT"; then - slxlog --echo "mount-stage4" "Could not mount stage4 from '$SLX_STAGE4' to '$MOUNTPOINT'" - exit 1 - fi -fi - -echo "Appending $MOUNTPOINT to /" -if ! mount -o "remount,add:1:$MOUNTPOINT=ro" /; then - slxlog --echo "mount-stage4" "Could not append mounted stage4 at '$MOUNTPOINT' to aufs at /" - exit 1 -fi - -# dbus reload needed eg. for gnome etc. and perhaps other service files which stage4 needs: -systemctl reload dbus.service - diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4 b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4 new file mode 100755 index 00000000..abc28f73 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_stage4 @@ -0,0 +1,64 @@ +#!/bin/bash +# Needs full bash + +. /opt/openslx/config + +[ -z "${SLX_STAGE4}" ] && { echo "SLX_STAGE4 is not set in /opt/openslx/config." && exit 1; } + +MOUNTPOINT="/opt/openslx/mnt/stage4" +mkdir -p "$MOUNTPOINT" + +if [[ "$SLX_STAGE4" == dnbd3* ]]; then + # 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=$(dnbd3-client -h "$SRV" -i "$IMAGE" -r "$SLX_STAGE4_RID") + RET=$? + [ "$RET" -eq "0" ] && break + echo "... didn't work ($RET)" + sleep 1 + done + if [ "$RET" -ne "0" ]; then + slxlog --echo "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE : $SLX_STAGE4_RID) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)" + exit $RET + fi + echo "Mounting $dnbd3 to $MOUNTPOINT" + if ! mount -t squashfs -o ro "$dnbd3" "$MOUNTPOINT"; then + slxlog --echo "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)" + exit 1 + fi +else + # Try nfs + echo "Mounting ${SLX_STAGE4} to $MOUNTPOINT" + if ! mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4" "$MOUNTPOINT"; then + slxlog --echo "mount-stage4" "Could not mount stage4 from '$SLX_STAGE4' to '$MOUNTPOINT'" + exit 1 + fi +fi + +echo "Appending $MOUNTPOINT to /" +if ! mount -o "remount,add:1:$MOUNTPOINT=ro" /; then + slxlog --echo "mount-stage4" "Could not append mounted stage4 at '$MOUNTPOINT' to aufs at /" + exit 1 +fi + +# dbus reload needed eg. for gnome etc. and perhaps other service files which stage4 needs: +systemctl reload dbus.service + +# tell systemd that stage4 was reached. +systemctl start stage4.target & + +exit 0 diff --git a/server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/mount-stage4.service b/server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/mount-stage4.service new file mode 120000 index 00000000..80390894 --- /dev/null +++ b/server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/mount-stage4.service @@ -0,0 +1 @@ +../mount-stage4.service \ No newline at end of file diff --git a/server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/nfs-mount.service b/server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/nfs-mount.service deleted file mode 120000 index 1936daef..00000000 --- a/server/modules/stage4-at-boot/etc/systemd/system/basic.target.wants/nfs-mount.service +++ /dev/null @@ -1 +0,0 @@ -../nfs-mount.service \ No newline at end of file -- cgit v1.2.3-55-g7522