diff options
-rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-mount_export | 24 |
1 files changed, 14 insertions, 10 deletions
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 c76634c7..506d8f0e 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 @@ -9,7 +9,14 @@ mkdir -p "$MOUNTPOINT" if [[ "$SLX_STAGE4" == dnbd3* ]]; then # dnbd3 it is - [ -z "${SLX_DNBD3_SERVERS}${SLX_DNBD3_PRIO_SERVERS}" ] && { echo "SLX_DNBD3(_PRIO)_SERVERS empty or not set in /opt/openslx/config." && exit 1; } + 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}') @@ -17,36 +24,33 @@ if [[ "$SLX_STAGE4" == dnbd3* ]]; then RET=1337 for SRV in $SLX_DNBD3_PRIO_SERVERS $SERVERS; do echo "Requesting $IMAGE from $SRV" - dnbd3=$(dnbd3-client -h "$SRV" -i "$IMAGE" -r 0) + dnbd3=$(dnbd3-client -h "$SRV" -i "$IMAGE" -r "$SLX_STAGE4_RID") RET=$? [ "$RET" -eq "0" ] && break echo "... didn't work ($RET)" - sleep 2 + sleep 1 done if [ "$RET" -ne "0" ]; then - slxlog "mount-stage4" "Could not get stage4 via dnbd3 ($IMAGE) ($SLX_DNBD3_PRIO_SERVERS / $SERVERS)" + 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 "mount-stage4" "Could not mount stage4 from '$dnbd3' to '$MOUNTPOINT' ($SRV, $IMAGE)" - echo "Fail." + 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 "mount-stage4" "Could not mount stage4 from '$SLX_STAGE4' to '$MOUNTPOINT'" - echo "Fail." + 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 "mount-stage4" "Could not append mounted stage4 at '$MOUNTPOINT to aufs at /" - echo "Fail." + slxlog --echo "mount-stage4" "Could not append mounted stage4 at '$MOUNTPOINT' to aufs at /" exit 1 fi |