summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/8021x8
-rwxr-xr-xsrc/netctl-auto24
2 files changed, 21 insertions, 11 deletions
diff --git a/src/lib/8021x b/src/lib/8021x
index 60f3552..1cd4343 100644
--- a/src/lib/8021x
+++ b/src/lib/8021x
@@ -23,6 +23,12 @@ wpa_call() {
do_debug wpa_cli "${args[@]}" "$@"
}
+## Check if an instance of the wpa supplicant is active on an interface
+# $1: interface name
+wpa_is_active(){
+ [[ $(wpa_call "$1" ping 2> /dev/null) == "PONG" ]]
+}
+
## Retrieves the state of an instance of the wpa supplicant
## Displays one of: DISCONNECTED, INTERFACE_DISABLED, INACTIVE, SCANNING,
## AUTHENTICATING, ASSOCIATING, ASSOCIATED, 4WAY_HANDSHAKE,
@@ -113,7 +119,7 @@ wpa_supplicant_scan() {
[[ $interface ]] || return 1
essids=$(mktemp --tmpdir essid.XXXXXXXX)
- if [[ "$(wpa_call "$interface" ping 2> /dev/null)" != "PONG" ]]; then
+ if ! wpa_is_active "$interface"; then
wpa_start "$interface" "${WPADriver:-nl80211,wext}" || return 1
spawned_wpa=1
fi
diff --git a/src/netctl-auto b/src/netctl-auto
index 3452969..1264469 100755
--- a/src/netctl-auto
+++ b/src/netctl-auto
@@ -5,33 +5,38 @@
. "$SUBR_DIR/rfkill"
AUTOWIFI="/usr/sbin/wpa_actiond -p /run/wpa_supplicant"
-ACTION_SCRIPT="/usr/lib/network/auto.action"
+ACTION_SCRIPT="$SUBR_DIR/auto.action"
if [[ $# != 2 || $1 != @(start|stop) ]]; then
exit_error "Usage: netctl-auto [start|stop] <interface>"
fi
+STARTSTOP=$1
INTERFACE=$2
PIDFILE="$STATE_DIR/wpa_actiond_$INTERFACE.pid"
PROFILE_FILE="$STATE_DIR/wpa_actiond_$INTERFACE.profile"
shift 2
-case $1 in
+case $STARTSTOP in
start)
- if [[ -e "/run/wpa_supplicant_$INTERFACE.pid" ]]; then
+ if wpa_is_active "$INTERFACE"; then
exit_error "The interface ($INTERFACE) is already in use"
fi
if [[ -x "$PROFILE_DIR/interfaces/$INTERFACE" ]]; then
source "$PROFILE_DIR/interfaces/$INTERFACE"
fi
- [[ $RFKill ]] && enable_rf "$INTERFACE" "$RFKill" || exit 1
+ if [[ $RFKill ]]; then
+ enable_rf "$INTERFACE" "$RFKill" || exit 1
+ fi
- WPA_CONF=$(wpa_make_config_file "$INTERFACE")
+ if ! WPA_CONF=$(wpa_make_config_file "$INTERFACE"); then
+ exit_error "Could not create the configuration file for interface '$INTERFACE'"
+ fi
list_profiles | while read -r profile; do
- report_notice "$profile"
+ report_debug "Examining profile '$profile'"
(
source "$PROFILE_DIR/$profile"
- is_yes "${ExcludeAuto:-no}"&& exit 1
+ is_yes "${ExcludeAuto:-no}" && exit 1
: ${Security:=none}
[[ $Interface != "$INTERFACE" ]] && exit 1
[[ $Connection != "wireless" ]] && exit 1
@@ -39,12 +44,10 @@ case $1 in
[[ $Security == "wpa-config" ]] && exit 1
printf "%s\n" "network={" "$(wpa_make_config_block)" "id_str=\"$profile\"" "}" >> "$WPA_CONF"
+ report_notice "Included profile '$profile'"
)
done
- # Kill any lingering WPA supplicants
- WPAConfigFile= wpa_stop "$INTERFACE" &> /dev/null
-
# Start the WPA supplicant
: ${WPADriver:=nl80211,wext}
WPAOptions+=" -W"
@@ -52,6 +55,7 @@ case $1 in
if $AUTOWIFI -i "$INTERFACE" -P "$PIDFILE" -a "$ACTION_SCRIPT" "$@"; then
exit 0
fi
+ wpa_stop "$INTERFACE"
fi
exit 1
;;