Openwrt seems to be hanging during bootup

Discussion about my Wifi Radio project at http://mightyohm.com/wifiradio/ or my WL-520gU talk at NOTACON.
FTaylor74
Posts: 10
Joined: Tue Oct 01, 2013 10:55 am

Re: Openwrt seems to be hanging during bootup

Post by FTaylor74 »

Gerben, I think we're getting closer. Not because of what happened, but because of what didn't.

Actions so far...
1) enabled /etc/init/mpd as you advised
2) executed /etc/init/mpd enabled && echo on on the command returned...
Start93
on on

3) executed chmod +x /etc/init.d/mpd to make sure the script has execution permission
4) Modified /etc/init.d/mpd as shown below. Added echo commands to trace my progress through the script. Echo $? was added to see if I could see a return code after executing each step.

None of these steps had any effect. I saw no echo messages related to mpd or mpc in any of the numerous reboots I executed.

I looked at ls -l /etc/init.d/ and noted that mps had the same permissions as virtually every other script in the /init.d/ directory.
I also looked at ls -l /usr/bin/. Both the mpc and mpd entries had a differnt permission from the other files. All of the others had an L or x in the first position. mpc and mpd had were both -rwxr-xr-x. Don't know if its important, but maybe it means something.

This sure seems like the mpd script is being completely bypassed... i.e., none of the code in the script is executed. So if the boot script is not hanging just before the mpd execution, it is skipping it altogether, imho.

what do you think?

Btw, I really appreciate you sticking with this. I may even pull for the Orange in the next World Cup!

Regards,
Ftaylor

Code: Select all

#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org
START=93

echo  "start93"
start() {

        echo "in 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
        echo "before start mpd"
        #start mpd
       echo "Start MPD"
        /usr/bin/mpd
        echo $?
        sleep 5
        echo "mpc repeat on"
        /usr/bin/mpc repeat on
        echo $?[/color]
        echo "mpc volume 90"
        /usr/bin/mpc volume 90
        echo $?[/color]
        echo "mpc load MPL"
        /usr/bin/mpc load MPL
        echo $?
        echo "mpc play 1"
        /usr/bin/mpc play 1
        echo $?

        #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
}

User avatar
gerben
Posts: 164
Joined: Sat Oct 16, 2010 8:41 am
Location: Netherlands

Re: Openwrt seems to be hanging during bootup

Post by gerben »

I'm not really a soccer fan, but thanks :-)

What happens if you manually run the init script; `/etc/init.d/mpd start`?

PS the 'l' at the beginning means symbolic links. A bit like a window shortcut. Pretty normal on openwrt/linux.

FTaylor74
Posts: 10
Joined: Tue Oct 01, 2013 10:55 am

Re: Openwrt seems to be hanging during bootup

Post by FTaylor74 »

Manually starting mpd...
Mpd echoes "start93" (first echo command in the script), but does not perform any other other echos or commands.
After echoing "start93", I'm returned to the command shell. At the command line, if I enter "mpc" to start the radio, I get the error

root@OpenWrt:/# /etc/init.d/mpd start
start93
root@OpenWrt:/# mpc
MPD_HOST and/or MPD_PORT environment variables are not set
error: problems getting a response from "localhost" on port 6600 : Connection re
fused


I think that indicates that the symbolic link(?) S93 is somehow broken.
Regards
Ftaylor74

User avatar
gerben
Posts: 164
Joined: Sat Oct 16, 2010 8:41 am
Location: Netherlands

Re: Openwrt seems to be hanging during bootup

Post by gerben »

Kind of looks like rc.common is not working. Very weird. Adding an echo in my `start()` function works just fine.
Not seeing anything other than the first echo, means there is something wrong with the init script. Not the sym-link.

I'd try creating my own init.d script, following the instruction in the link I provided previously.

The error you get from mpc, I do know. After more than a year of normal use, my router started giving the same error.
Don't know why, as I didn't change anything.
But running `export MPD_HOST=127.0.0.1` before running a mpc command fixed it for me.

User avatar
gerben
Posts: 164
Joined: Sat Oct 16, 2010 8:41 am
Location: Netherlands

Re: Openwrt seems to be hanging during bootup

Post by gerben »

PS. what router are you using?

FTaylor74
Posts: 10
Joined: Tue Oct 01, 2013 10:55 am

Re: Openwrt seems to be hanging during bootup

Post by FTaylor74 »

Hi Gerben,
I am pleased to announce that we finally got it working!

I took your advise, and rebuilt a very lean init script for mpd. (renamed /etc/init.d/mpd to /etc/init.d/xmpd, then created a new, empty mpd file). Previously, I had commented out everything but the bare essentials from the old mpd script, but wasn't having any luck with that.

At any rate, when I ran the new script. The radio did not start. I looked at the contents of /etc/rc.d/ and saw a pointer S93 to /etc/init.d/mpd, which I was expecting. I then ran mpc, and got the same error message:

MPD_HOST and/or MPD_PORT environment variables are not set
error: problems getting a response from "localhost" on port 6600 : Connection re
fused


I had always thought that the Start=93 line in the mpd script told the script to start process S93mpd. but it obviously wasn't doing that. So On a hunch, I added a new line at the beginning of the start() script, which read mpd.
Rebooted the router, and voila.. music!

Just to make sure, I removed the mpd statement and rebooted. This time nothing and running mpc at the command line still gives me an error. So, although I have it working now, I'm wondering if I have a created a kludge that works, rather than a proper invocation of mpd. It probably doesn't matter if it will work reliably, but after all of this, it like to know.

I really appreciate all the help you've given me. I think I would have eventually got here, but you saved me weeks of head scratching and frustraion.
Thanks again!
Regards
Ftaylor74

User avatar
gerben
Posts: 164
Joined: Sat Oct 16, 2010 8:41 am
Location: Netherlands

Re: Openwrt seems to be hanging during bootup

Post by gerben »

On OpenWRT you are probably okay. But on other linux systems, the init script might be called multiple times, even on shutdown. But it looks like OpenWRT only runs the init script once.
And no other process will run something like `/etc/init.d/mpd restart`

It's not pretty, but it will work just fine. Since the start() function was for some reason never called, this would be a nice fix.
Well done. I like people with perseverance.

Good luck, and feel free to ask any more questions you may run into.

FTaylor74
Posts: 10
Joined: Tue Oct 01, 2013 10:55 am

Re: Openwrt seems to be hanging during bootup

Post by FTaylor74 »

That's pretty much what I thought. I will let sleeping dogs lie.
Thanks again for your help. Now at last I can begin the fun part of the project.
Regards
Ftaylor74

Post Reply