[Devel] [PATCH 1/2] scripts: check service mountpoint is not empty in systemd-autofs-restart.sh

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Fri Jun 23 18:38:30 MSK 2017


Systemctl may fail. Let's check its result and mountpoint string after call.

https://jira.sw.ru/browse/PSBM-67544

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

diff --git a/scripts/systemd-autofs-restart.sh b/scripts/systemd-autofs-restart.sh
index 39abc26..d39e0cd 100755
--- a/scripts/systemd-autofs-restart.sh
+++ b/scripts/systemd-autofs-restart.sh
@@ -151,6 +151,16 @@ function restart_service {
 	local service=$1
 	local mountpoint=$($JOIN_CT $SYSTEMCTL show $service -p Where | sed 's/.*=//g')
 
+	if [ $? -ne 0 ]; then
+		echo "Failed to get mountpoint for $service service"
+		return 1
+	fi
+
+	if [ -z "$mountpoint" ]; then
+		echo "$service service mountpoint string is empty"
+		return 1
+	fi
+
 	# Try to move restored bind-mount aside and exit if Failed
 	# Nothing to do, if we Failed
 	save_mountpoint $mountpoint || return



More information about the Devel mailing list