#!/bin/bash ######################################################### # startsmgr.sh # # Version 1.0 # # Descr.: Script for starting and stopping the # # UC4 Service Manager on Unix ;-) # # install this script in root path of the # # UC4 ServiceManager # # Usage: startsmgr.sh # ######################################################### param=$1 PHRASE="UC4" SMGRINI="/home/uc4/ServiceManager/bin/ucybsmgr.ini" ### BEGIN INIT INFO # Provides: UC4 Automation Engine # Short-Description: Automatic start of UC4 Environment # Description: Automatic start of UC4 Environment ### END INIT INFO #UC4 Enviornment Settings UC4=/home/uc4/utility; export UC4 LD_LIBRARY_PATH=.:$UC4/bin:/usr/lib/oracle/11.2/client64/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH #echo $LD_LIBRARY_PATH cd /home/uc4/ServiceManager/bin echo "UC4 ServiceManager Control Script..." if [ "$#" != "1" ] ; then echo "ERROR: wrong arguments specified :-(" echo "usage: $0 " exit 1 fi getpid () { sleep 3 PID=`ps -ef | grep $PWD | grep ucy | awk '{ print $2 }'` echo "UC4 ServiceManager runs with PID: $PID" } case "$param" in start) #echo "nohup $PWD/ucybsmgr $PHRASE &" #nohup $PWD/ucybsmgr $PHRASE & su - uc4 -c 'PHRASE="UC4";. uc4_env.sh;cd /home/uc4/ServiceManager/bin;echo "nohup $PWD/ucybsmgr $PHRASE &";nohup $PWD/ucybsmgr $PHRASE &' getpid if [ "$PID" != "" ] ; then #get tcp/ip port from inifile PORT=`grep port= $SMGRINI` echo "Service $PHRASE successfully started!" echo "$0 uses $PORT" else echo "ERROR: could not start Service" echo " Check Logfiles!!" grep error /home/uc4/ServiceManager/temp/*00.txt exit 1 fi;; stop) getpid if [ "$PID" != "" ] ; then echo "kill -TERM $PID" kill -TERM $PID sleep 2 else echo "Service not active!" exit 1 fi getpid if [ "$PID" != "" ] ; then echo "ERROR: could not stop Service!!" exit 1 else echo "Service successfully stopped!!" fi;; status) getpid if [ "$PID" != "" ] ; then echo "Service is ONLINE" else echo "Service is OFFLINE" fi ;; esac exit 0