How to autorun wpa_supplicant on Debian startup

Posted by The Electric Muffin on Super User See other posts from Super User or by The Electric Muffin
Published on 2012-04-15T01:55:15Z Indexed on 2012/04/15 5:35 UTC
Read the original article Hit count: 218

I'd like to run wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant.conf on Debian startup (runlevels 2-5). I found some vague instructions from a related question that said to put a script in /etc/init.d/ and then symlink to it from the apropriate /etc/rcRUNLEVEL.d/ directories. However, I noticed that there are already some files named "wpasupplicant" that probably run at startup:

/etc/network/if-down.d/wpasupplicant

/etc/network/if-post-down.d/wpasupplicant

/etc/network/if-pre-up.d/wpasupplicant

/etc/network/if-up.d/wpasupplicant

They all are symlinks to the same script, /etc/wpa_supplicant/ifupdown.sh. It has a comment at the beginning saying it "[...] allows ifup(8), and ifdown(8) to manage wpa_supplicant(8) and wpa_cli(8) processes running in daemon mode." However, the closest it gets to calling wpa_supplicant itself is (in functions.sh):

WPA_SUP_BIN="/sbin/wpa_supplicant"
[snip]
start-stop-daemon --start --oknodo $DAEMON_VERBOSITY \
    --name $WPA_SUP_PNAME --startas $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE \
    -- $WPA_SUP_OPTIONS $WPA_SUP_CONF
[snip]
start-stop-daemon --stop --oknodo $DAEMON_VERBOSITY \
    --exec $WPA_SUP_BIN --pidfile $WPA_SUP_PIDFILE

Does that mean it's safe to make an init.d script for wpa_supplicant, and if so what would it look like?

General info:

  • Debian Squeeze (5.0)
  • official wpasupplicant package (v0.6.10-2.1)

The full contents of my system's functions.sh and ifupdown.sh are here (dependent, of course, on my system's uptime—it's a five-year-old laptop that greatly enjoys overheating):

functions.sh

ifupdown.sh

© Super User or respective owner

Related posts about debian

Related posts about debian-squeeze