From 0609a7f45cd8a6c513ba02713cadd6ce069f97ac Mon Sep 17 00:00:00 2001 From: Stephan Christann Date: Thu, 15 Jan 2015 11:09:22 +0100 Subject: [PATCH] Usability of init script improved. --- scm-server/src/main/nativepkg/init-script | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scm-server/src/main/nativepkg/init-script b/scm-server/src/main/nativepkg/init-script index 5e6cac53f3..db2d995147 100644 --- a/scm-server/src/main/nativepkg/init-script +++ b/scm-server/src/main/nativepkg/init-script @@ -62,20 +62,33 @@ appname=ScmServerDaemon # See how we were called. start() { - /opt/scm-server/bin/scm-server start + if [ $(ps aux | grep java | grep ${appname} | wc -l) = 0 ] + then + echo "SCM-Server will now be started" + /opt/scm-server/bin/scm-server start + else + echo "SCM-Server already running" + status + fi } stop() { - if [ ! status = 0 ] + if [ ! $(ps aux | grep java | grep ${appname} | wc -l) = 0 ] then + echo "SCM-Server will now be stopped" /opt/scm-server/bin/scm-server stop else - echo "SCM-Server is not running" + echo "SCM-Server is not running" fi } status() { - ps auxwww | grep java | grep ${appname} || echo "SCM-Server is not running" + if [ "$(ps auxwww | grep java | grep ${appname} | awk '{ print $1 " PID:" $2 }')" ]; then + echo "SCM-Server is running" + ps auxwww | grep java | grep ${appname} | awk '{ print " PID: " $2 }' + else + echo "SCM-Server is not running" + fi } restart() { @@ -84,6 +97,7 @@ restart() { STAT=$( ps auxwww | grep java | grep ${appname} | wc -l ) while [ $STAT -ne 0 ] do + echo -n . sleep 3 if [ $SECONDS -gt 300 ] then @@ -92,7 +106,9 @@ restart() { fi STAT=$( ps auxwww | grep java | grep ${appname} | wc -l ) done + status start + status } # See how we were called. @@ -115,4 +131,4 @@ case "$1" in exit 1 esac -exit $RETVAL \ No newline at end of file +exit $RETVAL