summaryrefslogtreecommitdiffstats
path: root/src/netctl-auto
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-12-31 14:01:03 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2012-12-31 14:01:03 +0100
commitecd9fd25076b715d23184317384e37315f5a8c8e (patch)
tree7dccbd0e8e65aac998282ae71887ee7798a5a543 /src/netctl-auto
parent454d7b63d70895ca8278c439ce75775d58c9ed6f (diff)
downloadnetctl-ecd9fd25076b715d23184317384e37315f5a8c8e.tar.gz
netctl-ecd9fd25076b715d23184317384e37315f5a8c8e.tar.xz
Fix netctl-auto
Curtis Shimamoto noted it did not work.
Diffstat (limited to 'src/netctl-auto')
-rwxr-xr-xsrc/netctl-auto24
1 files changed, 14 insertions, 10 deletions
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
;;