#!/bin/sh
### BEGIN INIT INFO
# Provides: phd
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Wrapper around the Phabricator Daemon launcher.
### END INIT INFO
NAME="phd"
DAEMON="/usr/src/phabricator/bin/$NAME"
DESC="Phabricator Daemon launcher"
# Include defaults if available
if [ -r /etc/default/phd ]; then
. /etc/default/phd
fi
# Exit if the package is not installed.
test -x $DAEMON || exit 0
# Load the VERBOSE setting and other rcS variables.
. /lib/init/vars.sh
# Define LSB log_* functions.
. /lib/lsb/init-functions
case "$1" in
start)
$DAEMON status --local >/dev/null 2>&1 && {
echo "Unable to start daemons because daemons are already running." >&2
exit 1
}
$DAEMON launch 'repository' || exit $?
exit 0
;;
stop)
$DAEMON stop || exit $?
exit 0
;;
status)
$DAEMON status --local || exit $?
exit 0
;;
list)
$DAEMON list || exit $?
exit 0
;;
restart)
$0 stop || exit $?
$0 start || exit $?
exit 0
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|status|list|restart}" >&2
exit 1
;;
esac
exit $RETVAL