Page 1 of 1

Running mpd mpc on power up

Posted: Fri Apr 24, 2009 8:04 am
by cj6666
Hi, this is a fun project! Thanks Jeff.

One question. How to start mpd and mpc automatically after power up?

Right now, I am using Hyper term to manually start them up.

Thanks in advance! CJ

Re: Running mpd mpc on power up

Posted: Fri Apr 24, 2009 1:31 pm
by ciphyre
The easiest way to do this is to create a start script in /etc/rc.d that starts mpd on any boot or reboot. There is already a script in /etc/init.d for mpd that is used for starting mpd so this task becomes even easier, since the START/KILL scripts in /etc/rc.d are just symbolic links to the scripts in /etc/init.d.

To get this to work, cd to /etc/rc.d and create two symbolic links as follows:

ln -s /etc/init.d/mpd S45mpd
ln -s /etc/init.d/mpd K45mpd

This will create a link called S45mpd that points to /etc/init.d/mpd and is used to start the service, and another link called K45mpd that points to /etc/init.d/mpd and is used to stop the service. The reason I used S45mpd/K45mpd as the names is so that these scripts start/stop after the important scripts like network etc.

The last station that was set using mpc and was playing on mpd will be played when the radio boots.

I needed to do the same thing so that is what worked for me.

Re: Running mpd mpc on power up

Posted: Sat Apr 25, 2009 6:26 am
by cj6666
Thanks ciphyre,

Using your tips, now mpd started automatically. But how about mpc? What's the best way to invoke mpc automatically? Without starting mpc, it won't play after power up.

I looked all over part 1 to 8 and I can't seem to find where that piece of information is hiding. I haven't build the LCD display or tuning control. But I can live with using a PC to telnet it and change station. But a simple power on and music starts playing will be fine with me probably 90% of time.

Thanks, CJ

Re: Running mpd mpc on power up

Posted: Sat Apr 25, 2009 8:26 am
by ciphyre
The music should start automatically, I just tried a reboot with the music playing and it rebooted and started without any manual intervention. I have also unplugged the router moved it to a new location and plugged it back in with the same results. The mpc command is not a service or daemon so it actually doesn't "run" or need to be running like mpd does. If you do a "ps -ef" while music is playing you won't see mpc running.

What are you trying to invoke with mpc? Did you have any music playing when you tried the reboot?

Re: Running mpd mpc on power up

Posted: Sat Apr 25, 2009 10:37 am
by cj6666
Weird...

I tried it again. With music playing, I pulled the plug. And Power on... hit return to see the OpenWrt prompt... typed mpd.. told me mpd is already running. But I hear no sound. type "mpc load cj_list" and "mpc play" to finally hear music appear.

Basically I followed MightyOhm's instruction up to part 5. Where I can start mpd and use mpc to control the deamon.

Could it be somewhere in the mpd.conf file that you configure something in addition to MightyOhm's instruction?

Thanks for your patience, CJ

Re: Running mpd mpc on power up

Posted: Sat Apr 25, 2009 11:19 am
by ciphyre
I am using playlists that I loaded using "mpc add"

Then playing a playlist using "mpc playlist 1"

Try that and reboot and see if there is any difference.

Re: Running mpd mpc on power up

Posted: Sat Apr 25, 2009 11:42 am
by cj6666
Finally got it. Yeah!!

I need to un-comment these two lines in "/etc/mpd.conf":

#pid_file "~/.mpd/mpd.pid"
...
#state_file "~/.mpd/mpstate"

these are where mpd stored the setting. And also comment these two lines in "/etc/inittab"

tts/0::..(etc)
ttys0::.. (etc)

So now, it will boot all the way and start mpd. I can just unplug it and listen to music now. Yeah. Sit back and relax!

Thanks a lot. CJ