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 <skinsbur...@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

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to