[package] update mpd to 0.15.2, cleanup init script (#6207)
[openwrt/svn-archive/archive.git] / sound / mpd / files / mpd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007 OpenWrt.org
3 START=93
4
5 start() {
6 #create mpd directories
7 md=`grep music_directory /etc/mpd.conf | cut -d "\"" -f 2 | sed "s/~/\/root/g"`
8 if [ ! -d $md ]; then
9 mkdir -p $md
10 fi
11 pld=`grep playlist_directory /etc/mpd.conf | cut -d "\"" -f 2 | sed "s/~/\/root/g"`
12 if [ ! -d $pld ]; then
13 mkdir -p $pld
14 fi
15 #create mpd db
16 /usr/bin/mpd --stdout --create-db
17
18 #optional export for mpc
19 #export MPD_HOST=127.0.0.1
20
21 #start mpd
22 /usr/bin/mpd
23
24 #generate playlist and start to play
25 /usr/bin/mpc listall | /usr/bin/mpc add -
26 /usr/bin/mpc play
27 /usr/bin/mpc repeat
28 }
29
30 stop() {
31 killall mpd
32 }