Posted on behalf of forum user 'Andrew DeFaria'.
Here's mine:
#!/bin/bash # servicename=p4dtg # /etc/rc.d/init.d/$servicename # #
Perforce Defect Tracking Replication Service # # p4dtgr is a service that
replicates information between Perforce and a Defect # Tracking System such as
Bugzilla. # # The following is derived from Ubuntu, not sure if they all apply
to CentOS. # # Provides: p4dtgr # Required-Start: $network # Required-Stop:
none # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # chkconfig: 2345 70 30 #
Short-Description: Starts the P4DTG Replication Service # Description: The
Perforce Defect Tracking Gateway Recplication Service \ # replicates information
between Perforce and a DTS like \ # Bugzilla. # processname: p4dtg-repl # Source
function library. . /etc/init.d/functions
logfile=/var/log/${servicename}.log P4DTG=/opt/perforce/p4dtg
p4dtg_bin=p4dtg-repl MAPNAME=pf-test-bugs-dev export P4TICKETS=/root/.p4tickets
logmsg() { msg=$1 echo $msg echo $msg >> $logfile } #
logmsg logerr() { msg=$1 logmsg "ERROR: $1" exit 1 } #
logerr start() { echo -n "Starting $servicename: " if [ !
-d "$P4DTG" ]; then logerr "Unable to find P4DTG in
$P4DTG" fi cd "$P4DTG" # If p4dtg-repl is already
running then there's nothing for us to do if pidofproc $p4dtg_bin >
/dev/null; then logmsg "P4DTG Service is already running" exit fi # If
run file exists remove it, but only if p4dtg-repl is not already running rm -f
repl/run-$MAPNAME ./$p4dtg_bin $MAPNAME & if [ $?
!= 0 ]; then logerr "Unable to launch P4DTG service" else
logmsg "P4DTG Service started" fi touch
/var/lock/subsys/$servicename cd $OLDPWD return 0 } stop() { echo -n
"Shutting down $servicename: " if ! pidofproc $p4dtg_bin
/dev/null; then echo "P4DTG Service is NOT running" fi # Touch
the stop file touch "$P4DTG/repl/stop-$MAPNAME" # Wait a few
seconds for the daemon to notice sleep 2 # Check to see that it stopped if
pidofproc $p4dtg_bin > /dev/null; then logerr "P4DTG Service is
still running after stop was requested" else logmsg "P4DTG Service
stopped" fi rm -f /var/lock/subsys/$servicename return 0 } case
"$1" in start) start ;; stop) stop ;; status) if pidofproc
$p4dtg_bin > /dev/null; then echo P4DTG Service is running else echo
P4DTG Service is NOT running fi ;; restart) stop start ;; *) echo "Usage:
$servicename {start|stop|status|restart}" exit 1 ;; esac exit $?
--
Please click here to see the post in its original format:
http://forums.perforce.com/index.php?/topic/2794-linux-service-script-for-p4dtg