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

Submitted by Stanislav Kinsburskiy on June 23, 2017, 3:38 p.m.

Details

Message ID 20170623153830.964277.51683.stgit@skinsbursky-vz7.qa.sw.ru
State New
Series "systemd-autofs-restart.sh: check systemctl results more"
Headers show

Commit Message

Stanislav Kinsburskiy June 23, 2017, 3:38 p.m.
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@virtuozzo.com>
---
 scripts/systemd-autofs-restart.sh |   10 ++++++++++
 1 file changed, 10 insertions(+)

Patch hide | download patch | download mbox

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