#!/bin/bash # # Startup script for syncronizing the hot backup server with the live server # # chkconfig: 345 95 10 # description: Keep the backup server in sync with the live (local) server # processname: p4hotbackup # the location of the p4 daemon binary [ -f /etc/p4-settings ] && . /etc/p4-settings test -f $P4D_LOGDIR/p4hotbackup.log || touch $P4D_LOGDIR/p4hotbackup.log chown perforce:perforce $P4D_LOGDIR/p4hotbackup.log RETVAL=0 prog="p4hotbackup" # Put this file in a temporary place so that # the daemon user has permission to write to it pidfile_x="/tmp/$prog.pid" pidfile="/var/run/$prog.pid" BIN="$P4D_SCRIPTDIR/p4hotbackup.sh $pidfile_x" # Source function library. . /etc/rc.d/init.d/functions # See how we were called. start() { echo -n $"Starting $prog: " daemon --check=$prog --user=$P4D_USER $BIN RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL } stop() { echo -n $"Shutting down $prog: " killproc $prog echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog # Move the temporary pid file to its proper location [ $RETVAL -eq 0 -a -f $pidfile_x ] && mv $pidfile_x $pidfile return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart|reload) stop start RETVAL=$? ;; status) status $prog RETVAL=$? ;; *) echo "Usage: $0 {start|stop|restart|reload|status}" exit 1 esac exit $RETVAL