diff options
author | James Rayner <james@archlinux.org> | 2010-02-21 12:10:21 +0100 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2010-02-21 12:10:21 +0100 |
commit | abb0cfbf8f933471847ced6e546c8a192c1169d7 (patch) | |
tree | c39eb7f43a40683309d882962ca5806ae6354af2 /src/wireless | |
parent | 63e1e4c2155c17cea7ed80e83d5feae3a0e44fa5 (diff) | |
download | netctl-abb0cfbf8f933471847ced6e546c8a192c1169d7.tar.gz netctl-abb0cfbf8f933471847ced6e546c8a192c1169d7.tar.xz |
Fix FS#18391, FS#18385, broken rfkill, handle hard more appropriately
Diffstat (limited to 'src/wireless')
-rw-r--r-- | src/wireless | 23 |
1 files changed, 20 insertions, 3 deletions
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: |