Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides: switchking
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop Switch King
# Description: Switch King init script. This script starts and stops Switch King daemon.
### END INIT INFO
set -e
export MONO_LOG_LEVEL=info
export MONO_LOG_MASK=dll
# Must be a valid filename
NAME=switchking
PIDFILE=/var/run/$NAME.pid
# This is the command to be run, give the full pathname
DAEMON="/usr/bin/mono /opt/switchking/bin/SwitchKing.exe"
DAEMON_OPTS="daemon 192.168.1.10 8080 192.168.1.10 8800"
case "$1" in
start)
echo -n "Starting daemon: "$NAME
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
stop)
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
if [ -e $PIDFILE ]; then
rm $PIDFILE
fi
echo "."
;;
restart)
echo -n "Restarting daemon: "$NAME
$0 stop
$0 start
echo "."
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0
EDIT2: Uppdaterat för SwitchKing 2.0