aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2017-07-21 16:07:12 +0200
committerKarel Kočí <karel.koci@nic.cz>2017-07-21 16:07:12 +0200
commit33ce0ce32ab70df1830205be2ee4e1dd53a1ae74 (patch)
tree68f267388d4ccb166763dc393999e8da6535d499
parent02a47abaf694261b3ed6f4f137a33a9afa141388 (diff)
downloadmyconfigs-33ce0ce32ab70df1830205be2ee4e1dd53a1ae74.tar.gz
myconfigs-33ce0ce32ab70df1830205be2ee4e1dd53a1ae74.tar.bz2
myconfigs-33ce0ce32ab70df1830205be2ee4e1dd53a1ae74.zip
Add ifrestart to user service
-rwxr-xr-xlocal/sbin/user-service.sh16
1 files changed, 16 insertions, 0 deletions
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