Rev 6914 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/sh### BEGIN INIT INFO# Provides: JatsBuildDaemon# Required-Start: $all# Required-Stop:# Default-Start: 3 4 5# Default-Stop: 0 1 6# X-Interactive: true# Short-Description: Jats Build Deamon# Description: The Jats Build Daemon provides automated build services### END INIT INFO#set -x## Start, stop 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## Note: Use /etc/init.d/buildtool setup# to perform additional setup of adding files to setup sequence##set -xBUILDUSR=buildadmWRAPPERSCRIPT=/work/buildtool/abtwrapperpid=0#pid null if not running, pid if running# Get the process group of the wrapper scriptcheck_running() {pid=`pgrep abtwrapper`[ -n "$pid" ] && pid=`ps -o pgid= -p $pid`}## Start daemons.#start() {check_runningif [ "$pid" ]; thenecho 'Running'elseecho 'Starting'if [ "$USER" != "$BUILDUSR" ]; then SU="su - ${BUILDUSR} -c "; else SU="/bin/sh -c"; fi$SU "${WRAPPERSCRIPT}" &fi}## Stop daemons.# Terminate the process group of the controlling script#stop() {check_runningecho "check_running returned $pid"if [ "$pid" ]; thenfor kpid in $pid ; doecho "Killing $kpid"kill -9 -$kpid 2>/dev/null 1>&2doneelseecho 'Not running'fi}## Status the daemons#status() {check_runningif [ "$pid" ]; thenecho 'buildtool running'elseecho 'buildtool not running'fi}## Setup init levels# Linux and Solaris are different#setup() {if [ ! -f /etc/init.d/buildtool ] ; thenecho "Error: /etc/init.d/buildtool does not exist"exit 1fimtype=`uname`if [ -x /usr/sbin/update-rc.d ] ; then mtype=Ubuntu; ficase "$mtype" inUbuntu)/usr/sbin/update-rc.d -f buildtool remove/usr/sbin/update-rc.d buildtool defaults;;Linux)for ii in 2 3 4 5; dofile=/etc/rc.d/rc$ii.d/S80buildtool[ -f $file ] || ln -s /etc/init.d/buildtool $filedonefor ii in 0 1 6 ; dofile=/etc/rc.d/rc$ii.d/K30buildtool[ -f $file ] || ln -s /etc/init.d/buildtool $filedone;;SunOS)for ii in 3; dofile=/etc/rc$ii.d/S80buildtool[ -f $file ] || ln -s /etc/init.d/buildtool $filedonefor ii in 0 1 S ; dofile=/etc/rc$ii.d/K30buildtool[ -f $file ] || ln -s /etc/init.d/buildtool $filedone;;*)echo "$0 setup - Unknown machine type: $mtype"exit 1;;esac}## Determine user command#case "$1" instart) start;;stop) stop;;status) statusRETVAL=$?;;restart) stopstart;;setup) setup;;*) echo "Usage: $0 {start|stop|restart|status|setup}"exit 1;;esacexit $RETVAL