Home » Questions » Computers [ Ask a new question ]

Start init script only once network interface is up

Start init script only once network interface is up

I have a headless media server using mpd running on gentoo. Mpd is configured to start at boot (and I don't have the rc scripts running in parallel either), but unfortunately mpd won't start if it can't bind to an interface. I've tried giving my wireless lan a static ip address but occasionally mpd won't start because the wlan card has not associated with the access point (I'm using wpa_supplicant).

Asked by: Guest | Views: 208
Total answers/comments: 2
Guest [Entry]

"In gentoo startup scripts, ( /etc/init.d/mpd in your example ) there should be a

depend() { ... }

section near the top. This is how init ends up determining the order for startup. You should put a requirement for network to finish before starting mpd there. I think the line is

need net

Check to see what is in the depend section in /etc/init.d/sshd. The same line from that should probably work if you add it to the mpd startup script."
Guest [Entry]

"From /etc/wpa_supplicant/ifupdown.sh:

# This file is executed by ifupdown in pre-up, post-up, pre-down and
# post-down phases of network interface configuration. It allows
# ifup(8), and ifdown(8) to manage wpa_supplicant(8) and wpa_cli(8)
# processes running in daemon mode.

Around about line 144 (on my copy) of the script it seems to do it's post-up operations - you should be able to place your launch mpd here unless someone can think of a better place."