#! /bin/sh ### BEGIN INIT INFO # Provides: p4d # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: Perforce SCM # Description: Perforce Source Code Management service # ### END INIT INFO # # Perforce Source Code Management # # Author: Tony Sweeney # # Install as /etc/init.d/p4d # # Create run level links with "[sudo ]update-rc.d p4d defaults" # Remove run level links with "[sudo ]update-rc.d p4d remove" # set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="Perforce SCM" # See how we've been called if [ -h $0 ]; then INITSCRIPT=`readlink $0` # Chase runlevel link else INITSCRIPT=$0 # Invoked directly fi NAME=`basename $INITSCRIPT` DAEMON=/usr/sbin/$NAME DAEMON_USER=perforce DAEMON_OPTS=-d PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME test -x $DAEMON || exit 0 # Perforce environment variables. if [ -f /etc/default/$NAME ]; then . /etc/default/$NAME fi # log_daemon_message lives here . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" start-stop-daemon --start --quiet \ --exec $DAEMON --chuid $DAEMON_USER -- $DAEMON_OPTS log_end_msg $? ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" # start-stop-daemon --stop --quiet --pidfile $PIDFILE \ # --oknodo --retry 60 --exec $DAEMON su - perforce -c ". /etc/default/p4d && p4 admin stop" log_end_msg $? ;; restart|force-reload) log_daemon_msg "Restarting $DESC" "$NAME" su - perforce -c ". /etc/default/p4d && p4 admin stop" start-stop-daemon --start --quiet \ --exec $DAEMON --chuid $DAEMON_USER -- $DAEMON_OPTS log_end_msg $? ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0