diff options
Diffstat (limited to 'core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-dnbd3_local_stage4')
-rwxr-xr-x | core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-dnbd3_local_stage4 | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-dnbd3_local_stage4 b/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-dnbd3_local_stage4 new file mode 100755 index 00000000..01b3d98a --- /dev/null +++ b/core/modules/dnbd3-proxy-mode/data/opt/openslx/scripts/systemd-dnbd3_local_stage4 @@ -0,0 +1,26 @@ +#!/bin/ash + +# Force immediate switch to localhost for stage4 if applicable +if [ -d "/mnt/dnbd3" ] && [ -b /dev/dnbd0 ] \ + && [ "$( cat /sys/block/dnbd0/net/rid )" -gt 0 ]; then + DNBD3_PORT=5003 + # give it some time to start + usleep 250000 + if ! grep -q -F 127.0.0.1 /sys/block/dnbd0/net/alt_servers; then + # add the server + if ! dnbd3-client -A "127.0.0.1:$DNBD3_PORT" -d /dev/dnbd0; then + echo "WARN: Cannot add localhost to dnbd0" >&2 + fi + fi + for i in 1 2 3 4 5 6 7; do + echo | busybox timeout 1 busybox nc 127.0.0.1 "$DNBD3_PORT" && break + echo "WARN: port wait fail #$i" + usleep ${i}00000 # tenths of a second + done + if ! dnbd3-client -s "127.0.0.1:$DNBD3_PORT" -d /dev/dnbd0; then + echo "ERROR: Cannot switch dnbd0 to localhost" >&2 + exit 1 + fi +fi + +exit 0 |