aboutsummaryrefslogtreecommitdiffstats
path: root/community/mpd/mpd.initd
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2017-10-19 11:42:08 +0200
committerSören Tempel <soeren+git@soeren-tempel.net>2017-10-19 12:19:07 +0200
commit5e15f7cfb012720adb56bc085947f98fc3f8effa (patch)
tree3d3e36ce01e3e594e5a41bdbcf14f8209542cf1c /community/mpd/mpd.initd
parent2f7c5415d86a218b7b55c037cb57954fa9086d0f (diff)
downloadaports-5e15f7cfb012720adb56bc085947f98fc3f8effa.tar.bz2
aports-5e15f7cfb012720adb56bc085947f98fc3f8effa.tar.xz
community/mpd: move from main
Diffstat (limited to 'community/mpd/mpd.initd')
-rw-r--r--community/mpd/mpd.initd48
1 files changed, 48 insertions, 0 deletions
diff --git a/community/mpd/mpd.initd b/community/mpd/mpd.initd
new file mode 100644
index 0000000000..c92bb982a6
--- /dev/null
+++ b/community/mpd/mpd.initd
@@ -0,0 +1,48 @@
+#!/sbin/openrc-run
+
+# init.d file for music player daemon
+
+NAME=mpd
+DAEMON=/usr/bin/$NAME
+CONF=/etc/mpd.conf
+
+depend() {
+ need localmount
+ use net netmount nfsmount esound pulseaudio
+ after firewall
+}
+
+checkconfig() {
+ [ -f "$CONF" ] && return 0
+ eerror "configuration file $CONF is missing"
+ return 1
+}
+
+get_pidfile() {
+ pidfile=$(awk '$1 == "pid_file" { print $2 }' "$CONF" | sed 's/"//')
+ pidfile=${pidfile:-/var/run/mpd/$NAME.pid}
+}
+
+start() {
+ checkconfig || return 1
+ get_pidfile
+ checkpath --owner ${M_USER:-mpd}:${M_GROUP:-audio} \
+ --directory ${pidfile%/*}
+
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet \
+ --exec ${DAEMON} -- ${MPD_OPTS}
+ eend $?
+}
+
+stop() {
+ get_pidfile
+ ebegin "Stopping ${NAME}"
+ mpd --kill
+ eend $?
+}
+
+start_pre() {
+ checkpath --directory --owner ${M_USER:-mpd} \
+ --mode 0775 /var/run/$NAME
+}