diff options
-rwxr-xr-x | src/lib/auto.action | 5 | ||||
-rwxr-xr-x | src/netctl-auto | 24 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/lib/auto.action b/src/lib/auto.action index ae49384..6cb6ff5 100755 --- a/src/lib/auto.action +++ b/src/lib/auto.action @@ -7,7 +7,6 @@ interface="$1" ssid="$2" profile="$3" action="$4" -PROFILE_FILE="$STATE_DIR/wpa_actiond_$interface.profile" # Is it possible that we don't get a profile?! [[ "$profile" ]] && load_profile "$profile" @@ -23,8 +22,6 @@ case $action in fi DHCPOptions+=" -K" ip_set || exit 1 - mkdir -p "$(dirname "$PROFILE_FILE")" - printf "%s" "$profile" > "$PROFILE_FILE" # JP: sandbox the eval if ! ( eval $ExecUpPost ); then # Failing ExecUpPost will take the connection down @@ -41,7 +38,7 @@ case $action in if ! ( eval $ExecDownPre ); then exit 1 fi - ip_unset && rm -f "$PROFILE_FILE" + ip_unset ;; LOST|REESTABLISHED) # Not handled. diff --git a/src/netctl-auto b/src/netctl-auto index a799b4b..7590110 100755 --- a/src/netctl-auto +++ b/src/netctl-auto @@ -4,8 +4,8 @@ . "$SUBR_DIR/8021x" . "$SUBR_DIR/rfkill" -AUTOWIFI="/usr/sbin/wpa_actiond -p /run/wpa_supplicant" -ACTION_SCRIPT="$SUBR_DIR/auto.action" +: ${ACTIOND:=wpa_actiond -p /run/wpa_supplicant} +: ${ACTION_SCRIPT:=$SUBR_DIR/auto.action} if [[ $# != 2 || $1 != @(start|stop) ]]; then exit_error "Usage: netctl-auto [start|stop] <interface>" @@ -14,7 +14,6 @@ fi STARTSTOP=$1 INTERFACE=$2 PIDFILE="$STATE_DIR/wpa_actiond_$INTERFACE.pid" -PROFILE_FILE="$STATE_DIR/wpa_actiond_$INTERFACE.profile" shift 2 case $STARTSTOP in @@ -52,7 +51,7 @@ case $STARTSTOP in : ${WPADriver:=nl80211,wext} WPAOptions+=" -W" if wpa_start "$INTERFACE" "$WPADriver" "$WPA_CONF"; then - if $AUTOWIFI -i "$INTERFACE" -P "$PIDFILE" -a "$ACTION_SCRIPT" "$@"; then + if $ACTIOND -i "$INTERFACE" -P "$PIDFILE" -a "$ACTION_SCRIPT" "$@"; then exit 0 fi wpa_stop "$INTERFACE" @@ -60,17 +59,14 @@ case $STARTSTOP in exit 1 ;; stop) - if [[ -e $PROFILE_FILE ]]; then - "$SUBR_DIR/network" stop "$(< "$PROFILE_FILE")" && rm -f "$PROFILE_FILE" - else - if [[ -x "$PROFILE_DIR/interfaces/$INTERFACE" ]]; then - source "$PROFILE_DIR/interfaces/$INTERFACE" - fi - wpa_stop "$INTERFACE" - ip link set dev "$INTERFACE" down - [[ $RFKill ]] && disable_rf "$INTERFACE" "$RFKill" + kill "$(< "$PIDFILE")" + if [[ -x "$PROFILE_DIR/interfaces/$INTERFACE" ]]; then + source "$PROFILE_DIR/interfaces/$INTERFACE" fi - timeout_wait 1 '[[ ! -f "$PIDFILE" ]]' || kill "$(< "$PIDFILE")" + timeout_wait 1 '! wpa_is_active "$INTERFACE"' || wpa_stop "$INTERFACE" + ip link set dev "$INTERFACE" down + [[ $RFKill ]] && disable_rf "$INTERFACE" "$RFKill" + exit 0 ;; esac |