mumble/mumble-server.init

96 lines
1.8 KiB
Bash

#! /bin/bash
#
### BEGIN INIT INFO
# Provides: mumble-server
# Required-Start: $network $local_fs $remote_fs dbus
# Required-Stop: $network $local_fs $remote_fs dbus
# Should-Start: mysql
# Should-Stop: mysql
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Mumble VoIP Server
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=mumble-server
PIDDIR=/var/run/$NAME
PIDFILE=$PIDDIR/$NAME.pid
DAEMON=/usr/sbin/murmurd
USER=mumble-server
GROUP=mumble-server
INIFILE=/etc/mumble-server.ini
DAEMON_OPTS="-ini $INIFILE"
MURMUR_DAEMON_START=0
MURMUR_USE_CAPABILITIES=0
MURMUR_LIMIT_NOFILE=0
MURMUR_LIMIT_RTPRIO=0
# Include murmur defaults if available
if [ -f /etc/default/$NAME ] ; then
. /etc/default/$NAME
fi
. /etc/rc.status
if [ "$MURMUR_LIMIT_NOFILE" -gt 0 ] ; then
ulimit -n $MURMUR_LIMIT_NOFILE
fi
if [ "$MURMUR_LIMIT_RTPRIO" -gt 0 ]; then
ulimit -r 1
fi
case "$1" in
start)
echo -n "Starting $NAME "
user=`sed -ne '/^uname=/s/.*=//p' < $INIFILE`
if [ -z "$user" ]; then
echo -n "${ext}No user configured in $INIFILE, refusing to run as root${norm}"
rc_status -v 6
else
eval HOME=~$user
cd $HOME
/sbin/start_daemon -p $PIDFILE -u $user $DAEMON $DAEMON_OPTS
rc_status -v
fi
;;
stop)
echo -n "Shutting down $NAME "
killproc -p $PIDFILE -TERM $DAEMON
rc_status -v
;;
try-restart|condrestart)
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
$0 try-restart
rc_status
;;
reload)
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking for service $NAME "
/sbin/checkproc $DAEMON
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit