diff options
-rw-r--r-- | src/connections/wireless | 22 | ||||
-rw-r--r-- | src/wireless | 23 | ||||
-rwxr-xr-x | wpa_actiond/netcfg-wpa_actiond | 9 |
3 files changed, 28 insertions, 26 deletions
diff --git a/src/connections/wireless b/src/connections/wireless index 5c9091a..a95496a 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -4,24 +4,6 @@ . $SUBR_DIR/wireless - -enable_rf() { - # Enable rfkill if necessary, or fail if it is hardware - if [[ -n "$RFKILL" ]]; then - local state=$(get_rf_state "$INTERFACE") || return 1 - if [[ "$state" != "up" ]]; then - if [[ "$RFKILL" == "soft" ]]; then - set_rf_state "$INTERFACE" up - sleep 1 - else - report_fail "radio is disabled on $INTERFACE" - return 1 - fi - fi - fi -} - - iwconfig_up() { quirk prescan && iwlist "$INTERFACE" scan &> /dev/null # bcm43xx @@ -66,7 +48,7 @@ wireless_up() { PROFILE="$1" load_profile "$PROFILE" - enable_rf || return 1 + enable_rf $INTERFACE $RFKILL $RFKILL_NAME || return 1 # Check if interface exists is_interface "$INTERFACE" || { report_fail "interface $INTERFACE does not exist"; return 1; } @@ -168,7 +150,7 @@ wireless_down() { # Any reason why a hardware switch should be considered on interface down? if [[ "$RFKILL" == "soft" ]]; then . "$SUBR_DIR/wireless" - set_rf_state "$INTERFACE" down || return 1 + set_rf_state "$INTERFACE" disabled $RFKILL_NAME || return 1 fi } diff --git a/src/wireless b/src/wireless index 0bd4dc1..d6b8b39 100644 --- a/src/wireless +++ b/src/wireless @@ -117,7 +117,7 @@ wpa_supplicant_scan_info() { } set_rf_state() { - local INTERFACE="$1" state="$2" PROFILE="$3" + local INTERFACE="$1" state="$2" RFKILL_NAME="$3" if [[ "$RFKILL" == "hard" ]]; then report_fail "Cannot set state on hardware rfkill switch" @@ -125,10 +125,10 @@ set_rf_state() { fi local path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") || return 1 case "$state" in - up) + enabled) echo 1 > "$path/state" ;; - down) + disabled) echo 0 > "$path/state" ;; esac @@ -172,5 +172,22 @@ get_rf_state() { esac } +enable_rf() { + local INTERFACE="$1" RFKILL="$2" RFKILL_NAME="$3" + # Enable rfkill if necessary, or fail if it is hardware + if [[ -n "$RFKILL" ]]; then + local state=$(get_rf_state "$INTERFACE") || return 1 + if [[ "$state" != "enabled" ]]; then + if [[ "$RFKILL" == "soft" ]]; then + set_rf_state "$INTERFACE" enabled $RFKILL_NAME + sleep 1 + else + report_fail "radio is disabled on $INTERFACE" + return 1 + fi + fi + fi +} + # vim: ft=sh ts=4 et sw=4: diff --git a/wpa_actiond/netcfg-wpa_actiond b/wpa_actiond/netcfg-wpa_actiond index 84a622d..a90d4cc 100755 --- a/wpa_actiond/netcfg-wpa_actiond +++ b/wpa_actiond/netcfg-wpa_actiond @@ -13,10 +13,13 @@ case $1 in exit ;; stop) + [[ -z $2 ]] && echo "Please specify an interface to stop" && exit 1 + interface=$2 + [[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface" stop_wpa $2 kill $(cat "/var/run/wpa_actiond_${2}.pid") - if [[ -n "$RFKILL" ]]; then # Enable radio if necessary - set_rf_state "$interface" down || exit $? + if [[ -n "$RFKILL" ]]; then + set_rf_state "$interface" disabled $RFKILL_NAME || exit $? fi exit ;; @@ -40,7 +43,7 @@ if [[ -f "$CONN_DIR/interfaces/$interface" ]]; then fi if [[ -n "$RFKILL" ]]; then # Enable radio if necessary - set_rf_state "$interface" up || exit $? + enable_rf $interface $RFKILL $RFKILL_NAME || exit $? fi WPA_CONF="$(make_wpa_config_file $interface)" |