diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-07-21 16:07:12 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-07-21 16:07:12 +0200 |
commit | 33ce0ce32ab70df1830205be2ee4e1dd53a1ae74 (patch) | |
tree | 68f267388d4ccb166763dc393999e8da6535d499 /local | |
parent | 02a47abaf694261b3ed6f4f137a33a9afa141388 (diff) | |
download | myconfigs-33ce0ce32ab70df1830205be2ee4e1dd53a1ae74.tar.gz myconfigs-33ce0ce32ab70df1830205be2ee4e1dd53a1ae74.tar.bz2 myconfigs-33ce0ce32ab70df1830205be2ee4e1dd53a1ae74.zip |
Add ifrestart to user service
Diffstat (limited to 'local')
-rwxr-xr-x | local/sbin/user-service.sh | 16 |
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 |