diff options
Diffstat (limited to 'remote')
| -rw-r--r-- | remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service | 2 | ||||
| -rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export | 32 |
2 files changed, 30 insertions, 4 deletions
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 index 922656f1..3deb3def 100644 --- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service +++ b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/nfs-mount.service @@ -1,6 +1,8 @@ [Unit] Description=Mount NFS Share [TEST] DefaultDependencies=no +Wants=setup-dnbd3.service +After=setup-dnbd3.service [Service] Type=oneshot 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 index b116c067..fd3e1b0a 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export @@ -2,14 +2,38 @@ . /opt/openslx/config -[ -z "${SLX_STAGE4_NFS}" ] && { echo "SLX_STAGE4_NFS is not set in /opt/openslx/config." && exit 1; } +[ -z "${SLX_STAGE4}" ] && { echo "SLX_STAGE4 is not set in /opt/openslx/config." && exit 1; } MOUNTPOINT="/opt/openslx/mnt/stage4" mkdir -p "$MOUNTPOINT" -echo "Mounting ${SLX_STAGE4_NFS} to $MOUNTPOINT" -mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4_NFS" "$MOUNTPOINT" || { echo "Fail." && exit 1; } + +if [[ "$SLX_STAGE4" == dnbd3* ]]; then + # dnbd3 it is + [ -z "${SLX_DNBD3_SERVERS}" ] && { echo "SLX_DNBD3_SERVERS empty or not set in /opt/openslx/config." && exit 1; } + # 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 $SERVERS; do + echo "Requesting $IMAGE from $SRV" + dnbd3=$(dnbd3-client -h "$SRV" -i "$IMAGE" -r 0) + RET=$? + [ "$RET" -eq "0" ] && break + echo "... didn't work ($RET)" + done + [ "$RET" -ne "0" ] && exit $RET + echo "Mounting $dnbd3 to $MOUNTPOINT" + mount -t squashfs -o ro "$dnbd3" "$MOUNTPOINT" || { echo "Fail."; exit 1; } +else + # Try nfs + echo "Mounting ${SLX_STAGE4} to $MOUNTPOINT" + mount -t nfs -o ro,async,nolock,vers=3 "$SLX_STAGE4" "$MOUNTPOINT" || { echo "Fail." && exit 1; } +fi + echo "Appending $MOUNTPOINT to /" -mount -o "remount,append:$MOUNTPOINT=ro" / || { echo "Fail." && exit 1; } +mount -o "remount,add:1:$MOUNTPOINT=ro" / || { echo "Fail." && exit 1; } # dbus reload needed eg. for gnome etc. and perhaps other service files which stage4 needs: systemctl reload dbus.service + |
