diff options
Diffstat (limited to 'net-scripts/net.modules.d/wpa_supplicant')
-rw-r--r-- | net-scripts/net.modules.d/wpa_supplicant | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/net-scripts/net.modules.d/wpa_supplicant b/net-scripts/net.modules.d/wpa_supplicant index c03774d..24e432a 100644 --- a/net-scripts/net.modules.d/wpa_supplicant +++ b/net-scripts/net.modules.d/wpa_supplicant @@ -14,19 +14,14 @@ wpa_cli() { LC_ALL=C /bin/wpa_cli "$@" } -# char* wpa_supplicant_provides(void) -# -# Returns a string to change module definition for starting up -wpa_supplicant_provides() { - echo "wireless" -} - # void wpa_supplicant_depend(void) # # Sets up the dependancies for the module wpa_supplicant_depend() { after macnet plug before interface + provide wireless + functions interface_exists } # bool wpa_supplicant_check_installed(void) @@ -48,21 +43,6 @@ wpa_supplicant_check_installed() { return "${installed}" } -# bool wpa_supplicant_check_depends(void) -# -# Checks to see if we have the needed functions -wpa_supplicant_check_depends() { - local f - - for f in interface_exists; do - [[ $( type -t "${f}" ) == "function" ]] && continue - eerror "wpa_supplicant: missing required function ${f}\n" - return 1 - done - - return 0 -} - # bool wpa_supplicant_check_extensions(char *interface) # # Checks to see if wireless extensions are enabled on the interface @@ -126,7 +106,8 @@ wpa_supplicant_kill() { pidfile="/var/run/wpa_cli-${iface}.pid" if ! clean_pidfile "${pidfile}" ; then ${report} && ebegin "Stopping wpa_cli on ${iface}" - start-stop-daemon --stop --exec /bin/wpa_cli --pidfile "${pidfile}" + start-stop-daemon --stop --exec /bin/wpa_cli \ + --pidfile "${pidfile}" ${report} && eend "$?" fi @@ -135,7 +116,7 @@ wpa_supplicant_kill() { if ! clean_pidfile "${pidfile}" ; then ${report} && ebegin "Stopping wpa_supplicant on ${iface}" start-stop-daemon --stop --exec /sbin/wpa_supplicant \ - --pidfile "${pidfile}" + --pidfile "${pidfile}" ${report} && eend "$?" else # Support wpa_supplicant-0.3.x @@ -149,7 +130,7 @@ wpa_supplicant_kill() { # If wpa_supplicant exits uncleanly, we need to remove the stale dir [[ -S "/var/run/wpa_supplicant/${iface}" ]] \ - && rm -f "/var/run/wpa_supplicant/${iface}" + && rm -f "/var/run/wpa_supplicant/${iface}" } # bool wpa_supplicant_associate(char *interface) @@ -206,7 +187,8 @@ wpa_supplicant_associate() { # Start wpa_supplicant on an interface and wait for association # Returns 0 (true) when successful, non-zero otherwise wpa_supplicant_pre_start() { - local iface="$1" opts timeout action=false cfgfile + local iface="$1" opts timeout action=false + local cfgfile="/etc/wpa_supplicant.conf" local actfile="/sbin/wpa_cli.action" # We don't configure wireless if we're being called from @@ -226,6 +208,8 @@ wpa_supplicant_pre_start() { local ifvar=$( bash_variable "${iface}" ) eval opts=\" \$\{wpa_supplicant_${ifvar}\} \" + [[ ${opts} != *" -D"* ]] \ + && ewarn "wpa_supplicant_${ifvar} does not define a driver" # We only work on wirelesss interfaces unless a driver for wired # has been defined @@ -237,9 +221,6 @@ wpa_supplicant_pre_start() { fi fi - [[ ${opts} != *" -D"* ]] \ - && ewarn "wpa_supplicant_${ifvar} does not define a driver" - # Check for rf_kill - only ipw supports this at present, but other # cards may in the future if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]]; then @@ -252,7 +233,7 @@ wpa_supplicant_pre_start() { # If wireless-tools is installed, try and apply our user config # This is needed for some drivers - such as hostap because they start # the card in Master mode which causes problems with wpa_supplicant. - if [[ $( type -t iwconfig_defaults ) == "function" ]]; then + if is_function iwconfig_defaults ; then if wpa_supplicant_check_extensions "${iface}" ; then iwconfig_defaults "${iface}" iwconfig_user_config "${iface}" @@ -261,15 +242,6 @@ wpa_supplicant_pre_start() { ebegin "Starting wpa_supplicant on ${iface}" - cfgfile="${opts##* -c}" - if [[ -n ${cfgfile} && ${cfgfile} != "${opts}" ]]; then - [[ ${cfgfile:0:1} == " " ]] && cfgfile="${cfgfile# *}" - cfgfile="${cfgfile%% *}" - else - cfgfile="/etc/wpa_supplicant.conf" - opts="${opts} -c/etc/wpa_supplicant.conf" - fi - if [[ ! -f ${cfgfile} ]]; then eend 1 "configuration file ${cfgfile} not found!" return 1 @@ -303,8 +275,7 @@ wpa_supplicant_pre_start() { fi start-stop-daemon --start --exec /sbin/wpa_supplicant \ - --pidfile "/var/run/wpa_supplicant-${iface}.pid" \ - -- ${opts} -B -i"${iface}" + -- ${opts} -B -c/etc/wpa_supplicant.conf -i"${iface}" eend "$?" || return 1 # Starting wpa_supplication-0.4.0, we can get wpa_cli to @@ -313,7 +284,6 @@ wpa_supplicant_pre_start() { mark_service_inactive "net.${iface}" ebegin "Starting wpa_cli on ${iface}" start-stop-daemon --start --exec /bin/wpa_cli \ - --pidfile "/var/run/wpa_cli-${iface}.pid" \ -- -a"${actfile}" -i"${iface}" \ -P"/var/run/wpa_cli-${iface}.pid" -B eend "$?" || return 1 |