From 33ce0ce32ab70df1830205be2ee4e1dd53a1ae74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 21 Jul 2017 16:07:12 +0200 Subject: Add ifrestart to user service --- local/sbin/user-service.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'local') diff --git a/local/sbin/user-service.sh b/local/sbin/user-service.sh index e48bb9d..632272c 100755 --- a/local/sbin/user-service.sh +++ b/local/sbin/user-service.sh @@ -27,6 +27,7 @@ while [ -n "$1" ]; do echo " start - start service" echo " stop - stop service" echo " restart - restart service" + echo " ifrestart - restart service if it's running" ;; -q) Q=false @@ -83,6 +84,21 @@ case "$OP" in exit 1 fi ;; + ifrestart) + $Q && echo "Restarting service $NAME..." + if status; then + if ! stop; then + $Q && echo " stop failed" + exit 1 + fi + if start; then + $Q && echo " ok" + else + $Q && echo " start failed" + exit 1 + fi + fi + ;; *) echo "Invalid operation!" exit 3 -- cgit v1.2.3