#!/bin/sh ### BEGIN INIT INFO # Provides: corrade # Required-Start: $local_fs $remote_fs $network $syslog $named # Required-Stop: $local_fs $remote_fs $network $syslog $named # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # X-Interactive: false # Short-Description: corrade service ### END INIT INFO ########################################################################### ## CONFIGURATION ## ########################################################################### CORRADE_USER="corrade" DAEMON="Corrade.exe" LOCK="Corrade.exe.lock" ########################################################################### ## INTERNALS ## ########################################################################### # Determine the path to mono and mono-service. MONO=$(which mono) MONOSERVER=$(which mono-service) start() { echo "Starting corrade..." HOMEDIR=`getent passwd $CORRADE_USER | cut -d: -f6` if [ -f $HOMEDIR/$DAEMON ]; then if [ -f $HOMEDIR/$LOCK ]; then rm -rf $HOMEDIR/$LOCK fi HOME="$HOMEDIR" start-stop-daemon --start -c $CORRADE_USER --pidfile $HOMEDIR/$LOCK --exec $MONOSERVER -d $HOMEDIR --background -- -l:$HOMEDIR/$LOCK $HOMEDIR/$DAEMON fi } stop() { echo "Stopping corrade..." HOMEDIR=`getent passwd $CORRADE_USER | cut -d: -f6` if [ -f $HOMEDIR/$DAEMON ]; then start-stop-daemon -o -c $CORRADE_USER -K -u $CORRADE_USER --pidfile $HOMEDIR/$LOCK --retry=TERM/30/KILL/5 -x $MONO -- -l:$HOMEDIR/$LOCK $HOMEDIR/$DAEMON if [ -f $HOMEDIR/$LOCK ]; then rm -rf $HOMEDIR/$LOCK fi fi } status() { dbpid=`pgrep -u $CORRADE_USER mono` if [ -z $dbpid ] ; then echo "corrade for USER $CORRADE_USER: not running." else echo "corrade for USER $CORRADE_USER: running (pid $dbpid)" fi } case "$1" in start) start ;; stop) stop ;; restart|reload|force-reload) stop start ;; status) status ;; *) echo "Usage: /etc/init.d/corrade {start|stop|reload|force-reload|restart|status}" exit 1 esac exit 0