add tryAddMount

we try to add a mount. if it fails, it will revert to the previous mount config.

there was a plan to make this work based on systemd-mount but we hit this bug - https://bugzilla.redhat.com/show_bug.cgi?id=1708996
This commit is contained in:
Girish Ramakrishnan
2021-05-21 17:31:54 -07:00
parent 59db625ad9
commit 0a5a24ba2e
3 changed files with 32 additions and 32 deletions

View File

@@ -23,9 +23,11 @@ mount_file_contents="$1"
where=$(echo "${mount_file_contents}" | grep "^Where=" | cut -d'=' -f 2)
mount_filename=$(systemd-escape -p --suffix=mount "$where")
echo "$mount_file_contents" > "/etc/systemd/system/${mount_filename}"
mount_file="/etc/systemd/system/${mount_filename}"
systemctl stop "${mount_filename}" || true
echo "$mount_file_contents" > "${mount_file}"
systemctl daemon-reload
systemctl enable --no-block --now "${mount_filename}" || true