problem with mpd starting

Discussion about my Wifi Radio project at http://mightyohm.com/wifiradio/ or my WL-520gU talk at NOTACON.
Post Reply
mred
Posts: 10
Joined: Thu Dec 29, 2011 2:30 am

problem with mpd starting

Post by mred »

I'm having trouble getting mpd to automatically start as the router boots. I've done the commandln -s /etc/init.d/mpd /etc/rc.d/S93mpd, but it doesn't seem to have worked. Is there a better way of automating startup of mpd? :?
User avatar
gerben
Posts: 164
Joined: Sat Oct 16, 2010 8:41 am
Location: Netherlands

Re: problem with mpd starting

Post by gerben »

Do you mean start MPD, or start music playback?
mred
Posts: 10
Joined: Thu Dec 29, 2011 2:30 am

Re: problem with mpd starting

Post by mred »

Both really. Specifically I meant to start mpd only, but if I can make it start, and play, that would be great too!
jeroen94704
Posts: 109
Joined: Sat Feb 13, 2010 4:27 am
Location: Eindhoven, the Netherlands

Re: problem with mpd starting

Post by jeroen94704 »

No, there is no better way to automatically start something at boot. Putting a script in /etc/init.d and then linking to it from /etc/rc.d is simply the way this is done.

What does "ls /etc/init.d/ -l" give? What about "ls /etc/rc.d/ -l" ?

Jeroen
mred
Posts: 10
Joined: Thu Dec 29, 2011 2:30 am

Re: problem with mpd starting

Post by mred »

Hi Jeroen,

root@OpenWrt:~# ls /etc/init.d/ -l
-rwxr-xr-x 1 root root 1756 Oct 4 2008 boot
-rwxr-xr-x 1 root root 281 Dec 2 2008 cron
-rwxr-xr-x 1 root root 6196 Dec 2 2008 dnsmasq
-rwxr-xr-x 1 root root 243 Oct 4 2008 done
-rwxr-xr-x 1 root root 1176 Dec 2 2008 dropbear
-rwxr-xr-x 1 root root 178 Dec 2 2008 firewall
-rwxr-xr-x 1 root root 1498 Oct 4 2008 fstab
-rwxr-xr-x 1 root root 1005 Dec 2 2008 httpd
-rwxr-xr-x 1 root root 1238 Oct 4 2008 led
-rwxr-xr-x 1 root root 767 Jan 1 00:04 mpd
-rwxr-xr-x 1 root root 4577 Oct 4 2008 netconfig
-rwxr-xr-x 1 root root 414 Oct 4 2008 network
-rwxr-xr-x 1 root root 2040 Dec 2 2008 nvram
-rwxr-xr-x 1 root root 134 Oct 4 2008 rcS
-rwxr-xr-x 1 root root 123 Oct 4 2008 sysctl
-rwxr-xr-x 1 root root 329 Dec 2 2008 telnet
-rwxr-xr-x 1 root root 99 Oct 4 2008 umount
-rwxr-xr-x 1 root root 154 Oct 4 2008 usb
-rwxr-xr-x 1 root root 140 Oct 4 2008 watchdog

root@OpenWrt:~# ls /etc/rc.d/ -l
lrwxrwxrwx 1 root root 17 Dec 2 2008 K40network -> ../init.d/network
lrwxrwxrwx 1 root root 16 Dec 2 2008 K99umount -> ../init.d/umount
lrwxrwxrwx 1 root root 15 Dec 2 2008 S02nvram -> ../init.d/nvram
lrwxrwxrwx 1 root root 19 Dec 2 2008 S05netconfig -> ../init.d/netconfig
lrwxrwxrwx 1 root root 14 Dec 2 2008 S10boot -> ../init.d/boot
lrwxrwxrwx 1 root root 15 Dec 2 2008 S20fstab -> ../init.d/fstab
lrwxrwxrwx 1 root root 13 Dec 2 2008 S39usb -> ../init.d/usb
lrwxrwxrwx 1 root root 17 Dec 2 2008 S40network -> ../init.d/network
lrwxrwxrwx 1 root root 18 Dec 2 2008 S45firewall -> ../init.d/firewall
lrwxrwxrwx 1 root root 14 Dec 2 2008 S50cron -> ../init.d/cron
lrwxrwxrwx 1 root root 18 Dec 2 2008 S50dropbear -> ../init.d/dropbear
lrwxrwxrwx 1 root root 15 Dec 2 2008 S50httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root 16 Dec 2 2008 S50telnet -> ../init.d/telnet
lrwxrwxrwx 1 root root 17 Dec 2 2008 S60dnsmasq -> ../init.d/dnsmasq
lrwxrwxrwx 1 root root 13 Dec 2 2008 S60led -> ../init.d/led
lrwxrwxrwx 1 root root 16 Jan 1 00:03 S93mpd -> /etc/init.d/mpd/
lrwxrwxrwx 1 root root 14 Dec 2 2008 S95done -> ../init.d/done
lrwxrwxrwx 1 root root 18 Dec 2 2008 S97watchdog -> ../init.d/watchdog
lrwxrwxrwx 1 root root 16 Dec 2 2008 S99sysctl -> ../init.d/sysctl

I guess there's stuff there I should have stripped out, but not quite knowing, I thought I'd leave it there....
jeroen94704
Posts: 109
Joined: Sat Feb 13, 2010 4:27 am
Location: Eindhoven, the Netherlands

Re: problem with mpd starting

Post by jeroen94704 »

So what's the content of your mpd script in /etc/init.d? Try "cat /etc/init.d/mpd"
mred
Posts: 10
Joined: Thu Dec 29, 2011 2:30 am

Re: problem with mpd starting

Post by mred »

Hi Jeroen,

Here are the results of doing that:

root@OpenWrt:~# cat /etc/init.d/mpd
#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org
START=93

start() {
#create mpd directories
md=`grep music_directory /etc/mpd.conf | cut -d "\"" -f 2 | sed "s/~/\/root/g"`
if [ ! -d $md ]; then
mkdir -p $md
fi
pld=`grep playlist_directory /etc/mpd.conf | cut -d "\"" -f 2 | sed "s/~/\/root/g"`
if [ ! -d $pld ]; then
mkdir -p $pld
fi
#create mpd db
/usr/bin/mpd --stdout --create-db

#optional export for mpc
#export MPD_HOST=127.0.0.1

#start mpd
/usr/bin/mpd
mpd

#generate playlist and start to play
/usr/bin/mpc listall | /usr/bin/mpc add -
/usr/bin/mpc play
/usr/bin/mpc repeat
}

stop() {
killall mpd
}

I am probably just overlooking something, so thankyou very much for your help :) And a very happy New Year to you and your family too! :D
jeroen94704
Posts: 109
Joined: Sat Feb 13, 2010 4:27 am
Location: Eindhoven, the Netherlands

Re: problem with mpd starting

Post by jeroen94704 »

Oh, wait, I think I see the problem. The symlink in /etc/rc.d/ does not point to the file "/etc/init.d/mpd", but to a directory "/etc/init.d/mpd/" (notice the trailing slash?). Removing the link in /etc/rc.d and recreating it without the trailing "/" should fix your problem.
mred
Posts: 10
Joined: Thu Dec 29, 2011 2:30 am

Re: problem with mpd starting

Post by mred »

Jeroen, you are a genius, and I am an idiot! I told you it would be something very simple! Thankyou so much for your help, isn't it amazing how much difference one keystroke can make!
Post Reply