Hello,
I updated the patch, so it fits to the current version 0.16.5-1. I
attached it.
Greetings
Christian
diff -Naur ../mpd-0.16.5-1-original/mpd-0.16.5//debian/mpd.dirs
mpd-0.16.5//debian/mpd.dirs
--- ../mpd-0.16.5-1-original/mpd-0.16.5//debian/mpd.dirs 2012-01-21
21:05:53.000000000 +0100
+++ mpd-0.16.5//debian/mpd.dirs 2012-01-21 21:08:54.000000000 +0100
@@ -1,4 +1,6 @@
etc
+etc/mpd
+etc/mpd/instances
usr/bin
usr/share/man/man1
var/log/mpd
diff -Naur ../mpd-0.16.5-1-original/mpd-0.16.5//debian/mpd.init.d
mpd-0.16.5//debian/mpd.init.d
--- ../mpd-0.16.5-1-original/mpd-0.16.5//debian/mpd.init.d 2012-01-21
21:05:53.000000000 +0100
+++ mpd-0.16.5//debian/mpd.init.d 2012-01-21 21:21:22.000000000 +0100
@@ -16,17 +16,19 @@
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin
+PKGNAME=mpd
NAME=mpd
+CONFIG_DIR=/etc/mpd/instances
DESC="Music Player Daemon"
DAEMON=/usr/bin/mpd
-MPDCONF=/etc/mpd.conf
+MPDCONF_SINGLE_INSTANCE=/etc/mpd.conf
START_MPD=true
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
if [ -n "$MPD_DEBUG" ]; then
set -x
@@ -45,12 +47,64 @@
fi
fi
-DBFILE=$(sed -n 's/^[[:space:]]*db_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p'
$MPDCONF)
-PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p'
$MPDCONF)
+read_dbfilename () {
+ DBFILE=$(sed -n 's/^[[:space:]]*db_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p'
$MPDCONF)
+}
+read_pidfilename () {
+ PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p'
$MPDCONF)
+}
mpd_start () {
+ # If /etc/mpd.conf exists we start this single instance and
+ # nothing else. This way we are backward compatible
+ if [ -e $MPDCONF_SINGLE_INSTANCE ]; then
+ MPDCONF=$MPDCONF_SINGLE_INSTANCE
+ NAME=$PKGNAME
+ read_pidfilename
+ mpd_start_instance
+ else
+ # Start instances for each config file in $CONFIG_DIR
+ for CONFIG in `cd $CONFIG_DIR; ls *.conf 2> /dev/null`; do
+ NAME=${CONFIG%%.conf}
+ MPDCONF=$CONFIG_DIR/$CONFIG
+ read_pidfilename
+ mpd_start_instance
+ done
+ fi
+}
+
+mpd_stop () {
+ if [ -e $MPDCONF_SINGLE_INSTANCE ]; then
+ MPDCONF=$MPDCONF_SINGLE_INSTANCE
+ NAME=$PKGNAME
+ read_pidfilename
+ mpd_stop_instance
+ else
+ # We proceed the same way like in mpd_start
+ # The drawback of this strategy is that if configs are deleted in
+ # between, those instance will not be stopped. The same problem
+ # arises if the pid-file is changed in the config.
+ #
+ # The package openvpn solves this problem by not letting the pid file be
+ # configured in each config. Instead the pid-filename is calculated by
the
+ # name of the config file. All the pid files are there in one directory
+ # and for each existing pid file the instance is stopped no matter if
+ # there is a config for that instance or not.
+ # To apply this solution to mpd, the pid filename would hava to be passed
+ # as an argument
+ for CONFIG in `cd $CONFIG_DIR; ls *.conf 2> /dev/null`; do
+ NAME=${CONFIG%%.conf}
+ MPDCONF=$CONFIG_DIR/$CONFIG
+ read_pidfilename
+ mpd_stop_instance
+ done
+ fi
+}
+
+mpd_start_instance () {
+ read_dbfilename
if [ "$START_MPD" != "true" ]; then
- log_action_msg "Not starting MPD: disabled by /etc/default/$NAME".
+ log_action_msg "Not starting MPD: disabled by /etc/default/$PKGNAME".
exit 0
fi
@@ -73,9 +127,9 @@
log_end_msg $?
}
-mpd_stop () {
+mpd_stop_instance () {
if [ "$START_MPD" != "true" ]; then
- log_failure_msg "Not stopping MPD: disabled by /etc/default/$NAME".
+ log_failure_msg "Not stopping MPD: disabled by /etc/default/$PKGNAME".
exit 0
fi
if [ -z "$PIDFILE" ]; then
diff -Naur ../mpd-0.16.5-1-original/mpd-0.16.5//debian/mpd.postinst
mpd-0.16.5//debian/mpd.postinst
--- ../mpd-0.16.5-1-original/mpd-0.16.5//debian/mpd.postinst 2012-01-21
21:05:53.000000000 +0100
+++ mpd-0.16.5//debian/mpd.postinst 2012-01-21 22:03:23.000000000 +0100
@@ -3,7 +3,11 @@
umask 0022
ACTION="$1"
VERSION="$2"
-MPDCONF="/etc/mpd.conf"
+if [ -e /etc/mpd.conf ]; then
+ MPDCONF="/etc/mpd.conf"
+else
+ MPDCONF=/etc/mpd/instances/$(ls /etc/mpd/instances/ | head -n 1)
+fi
PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p'
$MPDCONF)
if [ "$ACTION" != "configure" ]; then
diff -Naur ../mpd-0.16.5-1-original/mpd-0.16.5//debian/README.Debian
mpd-0.16.5//debian/README.Debian
--- ../mpd-0.16.5-1-original/mpd-0.16.5//debian/README.Debian 2012-01-21
21:05:53.000000000 +0100
+++ mpd-0.16.5//debian/README.Debian 2012-01-21 21:08:54.000000000 +0100
@@ -15,6 +15,12 @@
value to an appropriate interface, or comment it out to enable listening
on all network interfaces.
+If you want to start multiple instances of mpd as a system service, place
+a .conf file for each instance in /etc/mpd/instances and delete /etc/mpd.conf.
+Be carefull that you do add or remove new instance only when mpd is stopped.
+Make sure that each instance has a different pid_file, state_file and port.
+Probably you want to specify a different audio_output for each, too.
+
When using ALSA with dmix, you may run into problems sharing the sound card
between the "mpd" user and your own account. A workaround is to use ALSA's
"ipc_key_add_uid" and "ipc_perm" directives. See the ALSA documentation for