[Devel] systemd-autofs-restart.sh: return meaningful value from restore_mountpoint

Submitted by Stanislav Kinsburskiy on July 24, 2017, 8:27 a.m.

Details

Message ID 20170724082741.40930.89067.stgit@skinsbursky-vz7.qa.sw.ru
State New
Series "systemd-autofs-restart.sh: return meaningful value from restore_mountpoint"
Headers show

Commit Message

Stanislav Kinsburskiy July 24, 2017, 8:27 a.m.
Its result is threated as a reason to print or supress error message.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 scripts/systemd-autofs-restart.sh |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/systemd-autofs-restart.sh b/scripts/systemd-autofs-restart.sh
index 72d2ef7..610960d 100755
--- a/scripts/systemd-autofs-restart.sh
+++ b/scripts/systemd-autofs-restart.sh
@@ -128,23 +128,28 @@  function save_mountpoint {
 function restore_mountpoint {
 	local mountpoint=$1
 
-	[ -n "$bindmount" ] || return
+	[ -n "$bindmount" ] || return 0
 
 	# Umount file system, remounted by systemd, if any
 	top_mount_fs_type=$(get_fs_type $mountpoint)
 	if [ $? -ne 0 ]; then
 		echo "$top_mount_fs_type"
-		return
+		return 0
 	fi
 
 	# Nothing to do, if no file system is on top of autofs
 	if [ "$top_mount_fs_type" != "autofs" ]; then
-		$JOIN_CT umount $mountpoint || echo "Failed to umount $mountpoint"
+		$JOIN_CT umount $mountpoint
+		if [ $? -ne 0 ]; then
+			echo "Failed to umount $mountpoint"
+			return 1
+		fi
 	fi
 
 	# Restore origin file system even if we failed to unmount the new one
-	bind_mount $bindmount $mountpoint
+	bind_mount $bindmount $mountpoint || return 1
 	remove_bindmount
+	return 0
 }
 
 function restart_service {