3

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

5

If your goal is to get your wireless interface configured on startup (vs. putting the wpa_supplicant command in a script for other reasons), you can use /etc/network/interfaces and the ordinary config file wpa_passphrase generates to achieve this result.

In /etc/network/interfaces (assuming wlan0 is your wireless interface and the config from wpa_passphrase is in /root/your-wpa.conf):

allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-conf /root/your-wpa.conf

On my system I have a tab (not spaces) at the start of the "wpa-conf" line. Had trouble entering a tab for the web when typing this response. Not sure if that matters.

I did not need to edit or do anything to the WPA conf file. It is what I get from the command

wpa_passphrase myssid mysecret >wpa.conf

See How to use a WiFi interface on Debian.org and /usr/share/doc/wpasupplicant/README.wpa_supplicant.conf.gz locally.

I tested this on Jessie and no longer have any Squeeze systems left - but I imagine you have upgraded in the 4 years since asking the question.

-1

Edit the wpa_supplicant.conf file and add it to /etc/network/interfaces

http://wiki.debian.org/WPA#Why.3F

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.