Subversion Repositories DevTools

Rev

Rev 850 | Blame | Last modification | View Log | RSS feed

#!/bin/sh
#set -x
#
# buildtool     This shell script takes care of starting and stopping
#               buildtool.
#
# Note: This must be a 'sh' compatible script
#       Solaris8 uses sh to source the script. It is not run at startup
#
# Note: This file should be installed into /etc/init.d
#       May need addional configuration to add the file to the startup sequence

pid=0

#pid null if not running, pid if running
check_running() {
        pid=`ps -fe|grep java|grep abtdD.jar|awk '{print $2}'`
}

start() {
        # Start daemons.
        check_running
        if [ "$pid" ]; then
          echo 'running'
        else
          echo 'starting'
          su - buildadm -c 'source /etc/profile;unset GBE_PLATFORM;jats -NoExportVars eprog /home/buildadm/buildtool/abtlaunch 2>/tmp/buildtool 1>&2' &
        fi
}

stop() {
        # Stop daemons.
        check_running
        echo "check_running returned $pid"

        if [ "$pid" ]; then
        for kpid in $pid ; do
            echo "killing $kpid"
            kill -9 $kpid 2>/dev/null 1>&2
        done
        else
          echo 'not running'
        fi
}

status() {
        # Stop daemons.
        check_running

        if [ "$pid" ]; then
          echo 'running'
        else
          echo 'not running'
        fi
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status buildtool
        RETVAL=$?
        ;;  
  restart)
       stop
       start
       ;;

  *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac

exit $RETVAL