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

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Mon Jul 24 11:27:41 MSK 2017


Its result is threated as a reason to print or supress error message.

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

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 {



More information about the Devel mailing list