mount: if unmount failed, do not proceed
This commit is contained in:
@@ -27,9 +27,13 @@ mount_filename=$(systemd-escape -p --suffix=mount "$where")
|
||||
mount_file="/etc/systemd/system/${mount_filename}"
|
||||
|
||||
# cleanup any previous mount of same name (after midway box crash?)
|
||||
if systemctl -q is-active mnt-volumes-ext4data.mount; then
|
||||
if systemctl -q is-active "${mount_filename}"; then
|
||||
echo "Previous mount active, unmounting"
|
||||
systemctl stop "${mount_filename}" || true
|
||||
# unmounting can fail if a user is cd'ed into the directory. if we go ahead and mount anyway, systemd says "active" because it's referring to the previous mount config
|
||||
if ! systemctl stop "${mount_filename}"; then
|
||||
echo "Failed to unmount"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$mount_file_contents" > "${mount_file}"
|
||||
@@ -38,7 +42,7 @@ systemctl daemon-reload
|
||||
|
||||
if ! timeout "${timeout}" systemctl enable --now "${mount_filename}"; then
|
||||
echo "Failed to mount"
|
||||
exit 1
|
||||
exit 3
|
||||
fi
|
||||
|
||||
echo "Mount succeeded"
|
||||
|
||||
Reference in New Issue
Block a user