Package: mumble-server
Version: 1.2.3-349-g315b5f5-2.2
Severity: wishlist
Tags: patch

Hi Ron,

this init.d file adds an initial support for running multiple
instances of murmurd.  The package will need some more changes to
successfully enable this, and it will be post-wheezy work, but I would
like to use this bug to track all the needed changes.

TODO:
- Move /etc/mumble-server.ini to /etc/mumble-server/mumble-server.ini in 
{post,pre}{inst,rm}

Ondrej

-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
#! /bin/sh
#
### 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:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Mumble VoIP Server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=mumble-server
DESC="Mumble VoIP Server"
PIDDIR=/var/run/mumble-server
DAEMON=/usr/sbin/murmurd
USER=mumble-server
GROUP=mumble-server

test -x $DAEMON || exit 0

MURMUR_DAEMON_START=0
MURMUR_USE_CAPABILITIES=0
MURMUR_LIMIT_NOFILE=0

# Include murmur defaults if available
if [ -f /etc/default/$NAME ] ; then
	. /etc/default/$NAME
fi

if [ "$MURMUR_DAEMON_START" != "1" ] ; then
    log_warning_msg "Not starting $DESC $NAME, disabled via /etc/default/$NAME"
    exit 0
fi

.. /lib/init/vars.sh
.. /lib/lsb/init-functions

if [ -n "$2" ]; then
    INSTANCES=$2
else
    INSTANCES=$(ls -1 /etc/mumble-server/*.ini | xargs -i basename {} .ini)
fi

if [ "$MURMUR_LIMIT_NOFILE" -gt 0 ] ; then
	ulimit -n $MURMUR_LIMIT_NOFILE
fi

[ -d $PIDDIR ] || install -o $USER -d $PIDDIR

do_start() {
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started

    [ -z "$1" ] && exit 1
    INSTANCE=$1
    PIDFILE=$PIDDIR/$INSTANCE.pid
    INIFILE=/etc/mumble-server/$INSTANCE.ini
    DAEMON_OPTS="-ini $INIFILE"

    start-stop-daemon --start --quite --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
	|| return 1

    if [ "$MURMUR_USE_CAPABILITIES" != "1" ] ; then
	start-stop-daemon --start --quiet \
	    --pidfile $PIDFILE \
	    --chuid $USER:$GROUP \
	    --exec $DAEMON \
	    -- $DAEMON_OPTS \
	    || return 2
    else
	start-stop-daemon --start --quiet \
	    --pidfile $PIDFILE \
	    --exec $DAEMON \
	    -- $DAEMON_OPTS \
	    || return 2
    fi
}

do_stop() {
    [ -z "$1" ] && exit 1
    PIDFILE=$PIDDIR/$1.pid
    start-stop-daemon --stop --quiet \
	--retry=TERM/30/KILL/5 \
	--pidfile $PIDFILE \
	--user $USER \
	--exec $DAEMON
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    rm -f $PIDFILE
    return "$RETVAL"
}

do_reload() {
    [ -z "$1" ] && exit 1
    PIDFILE=$PIDDIR/$1.pid
    start-stop-daemon --stop --quiet \
	--signal 1 \
	--pidfile $PIDFILE \
	--user $USER \
	--exec $DAEMON
    return 0
}

case "$1" in
  start)
  	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" 
	for INSTANCE in $INSTANCES; do
	    do_start $INSTANCE
	    case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_daemon_msg "$INSTANCE" ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ; exit 1 ;;
	    esac
	done
	[ "$VERBOSE" != no ] && log_end_msg 0
	;;
  stop)
  	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC"
	for INSTANCE in $INSTANCES; do
	    do_stop $INSTANCE
	    case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_daemon_msg "$INSTANCES" ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	    esac
	done
	;;
  logrotate)
  	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC"
	for INSTANCE in $INSTANCES; do
	    do_reload $INSTANCE
	    case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_daemon_msg "$INSTANCES" ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	    esac
	done
	;;
  restart|force-reload)
 	[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC"
	for INSTANCE in $INSTANCES; do
	    do_stop $INSTANCE
	    case "$?" in
		0|1)
		    do_start $INSTANCE
		    case "$?" in
			0) [ "$VERBOSE" != "no" ] && log_daemon_msg "$INSTANCE" ;;
			*) [ "$VERBOSE" != "no" ] && log_end_msg 1 ;;
		    esac
		    ;;
		*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	    esac
	done
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload|logrotate}" >&2
	exit 3
	;;
esac

exit 0
/var/log/mumble-server/*.log {
        weekly
        rotate 7
        compress
        delaycompress
        missingok
        postrotate
                /etc/init.d/mumble-server logrotate
        endscript
}

Reply via email to