diff options
-rw-r--r-- | src-wireless/netcfg-auto-wireless | 8 | ||||
-rw-r--r-- | src/connections/ethernet-iproute | 2 | ||||
-rw-r--r-- | src/connections/wireless | 20 | ||||
-rw-r--r-- | src/globals | 1 | ||||
-rw-r--r-- | src/netcfg-menu | 2 | ||||
-rw-r--r-- | src/network | 3 | ||||
-rw-r--r-- | src/wireless | 50 |
7 files changed, 44 insertions, 42 deletions
diff --git a/src-wireless/netcfg-auto-wireless b/src-wireless/netcfg-auto-wireless index e83f55b..e3c9727 100644 --- a/src-wireless/netcfg-auto-wireless +++ b/src-wireless/netcfg-auto-wireless @@ -13,14 +13,14 @@ wifi_auto() report_try "Scanning for networks" source $IFACE_DIR/$interface - if [[ $RFKILL ]]; then - set_rf_state $interface up + if [[ -n "$RFKILL" ]]; then + set_rf_state "$interface" up fi set_interface up "$interface" # uses iproute methods---is it there any value to providing option to use ifconfig? - networks="$(list_networks $interface)" + networks=$(list_networks "$interface") - if [[ -z $networks ]]; then + if [[ -z "$networks" ]]; then set_interface forcedown "$interface" exit_fail "- No networks available." fi diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute index b86b9f4..855ddb6 100644 --- a/src/connections/ethernet-iproute +++ b/src/connections/ethernet-iproute @@ -128,7 +128,7 @@ ethernet_down() { # Returns status of profile - is it still functional? ethernet_status() { - if ! ip link show dev ra0 | fgrep -q "state UP"; then + if ! ip link show dev "$INTERFACE" | fgrep -q "state UP"; then return 1 fi } diff --git a/src/connections/wireless b/src/connections/wireless index 29e4112..b923b0b 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -10,10 +10,10 @@ wireless_up() { . "$SUBR_DIR/8021x" . "$SUBR_DIR/wireless" - if [[ $RFKILL ]]; then - if [[ ! $(get_rf_state $INTERFACE) == "up" ]]; then - if [[ $RFKILL == "soft" ]]; then - set_rf_state $INTERFACE up + if [[ -n "$RFKILL" ]]; then + if [[ ! "$(get_rf_state "$INTERFACE")" == "up" ]]; then + if [[ "$RFKILL" == "soft" ]]; then + set_rf_state "$INTERFACE" up sleep 1 else report_fail "radio is disabled on $INTERFACE" @@ -141,7 +141,7 @@ wireless_up() { local WPA_CONF="${TMPDIR:-/tmp}/wpa.${1// /}" # substitute spaces out # make empty tmp dir with correct permissions, rename it rm -rf "$WPA_CONF" - mv -f $(mktemp -d) "$WPA_CONF" || return 1 + mv -f "$(mktemp -d)" "$WPA_CONF" || return 1 echo "ctrl_interface=/var/run/wpa_supplicant" >> "$WPA_CONF/wpa.conf" # we know $WPA_CONF now has no spaces, but it may have other nasty chars, so still needs to be quoted echo "ctrl_interface_group=${WPA_GROUP:-wheel}" >> "$WPA_CONF/wpa.conf" @@ -216,18 +216,18 @@ wireless_down() { # Handle wireless kill switches # Any reason why a hardware switch should be considered on interface down? - if [[ $RFKILL == "soft" ]]; then + if [[ "$RFKILL" == "soft" ]]; then . "$SUBR_DIR/wireless" - set_rf_state $INTERFACE down + set_rf_state "$INTERFACE" down fi } # Returns status of profile - is it still functional? wireless_status() { - load_profile $1 - if [[ "$(iwgetid -r)" -ne $ESSID ]]; then + load_profile "$1" + if [[ "$(iwgetid -r)" -ne "$ESSID" ]]; then return 1 - elif ! ip link show dev ra0 | fgrep -q "state UP"; then + elif ! ip link show dev "$INTERFACE" | fgrep -q "state UP"; then return 1 fi diff --git a/src/globals b/src/globals index df771a9..bd60b35 100644 --- a/src/globals +++ b/src/globals @@ -121,3 +121,4 @@ function load_hooks() { load_hooks + diff --git a/src/netcfg-menu b/src/netcfg-menu index 78367d2..40f20b2 100644 --- a/src/netcfg-menu +++ b/src/netcfg-menu @@ -29,7 +29,7 @@ fi ANSWER=$(mktemp --tmpdir menu.XXXXXXXX) || exit 1 # Set timeout -if [ -z "$1" ]]; then +if [[ -z "$1" ]]; then TIMEOUT="0" else TIMEOUT="$1" diff --git a/src/network b/src/network index 69bb1e3..28250b4 100644 --- a/src/network +++ b/src/network @@ -196,7 +196,7 @@ profile_down() fi report_try "$PROFILE down" - if [[ "$(get_iface_prof $INTERFACE)" == "external" ]]; then + if [[ "$(get_iface_prof "$INTERFACE")" == "external" ]]; then report_fail "$interface was connected by another application" exit 1 fi @@ -354,6 +354,7 @@ set_interface() sleep "${UP_SLEEP:-2}" ;; down|forcedown|down-old|forcedown-old) + # should this be placed elsewhere? if ! ( eval $IFACE_DOWN ); then return 1 fi diff --git a/src/wireless b/src/wireless index 4e66bfa..3592d5e 100644 --- a/src/wireless +++ b/src/wireless @@ -125,7 +125,7 @@ list_networks() } list_networks() { - wpa_supplicant_scan_info $1 1,5 + wpa_supplicant_scan_info "$1" 1,5 } wpa_supplicant_scan_info() { @@ -136,7 +136,7 @@ wpa_supplicant_scan_info() { [[ -z "$INTERFACE" ]] && return 1 essids=$(mktemp --tmpdir essid.XXXXXXXX) - wpa_supplicant -B -i$INTERFACE -Dwext -C/var/run/wpa_supplicant -P/var/run/wpa_supplicant.pid + wpa_supplicant -B -i"$INTERFACE" -Dwext -C/var/run/wpa_supplicant -P/var/run/wpa_supplicant.pid wpa_cli -i "$INTERFACE" scan &> /dev/null sleep 2.5 wpa_cli -i "$INTERFACE" scan_results | @@ -145,7 +145,7 @@ wpa_supplicant_scan_info() { sort -rn -k3 | sort -u -k5 | sort -rn -k3 | - cut -f$fields > "$essids" + cut -f"$fields" > "$essids" # Fields are tab delimited # Remove extraneous output from wpa_cli @@ -154,7 +154,7 @@ wpa_supplicant_scan_info() { # Re-sort by strength as the removal disorders the list # Cut to the AP/essid fields only - kill $(cat /var/run/wpa_supplicant.pid) + kill "$(cat /var/run/wpa_supplicant.pid)" # File of 0 length, ie. no ssid's. if [[ ! -s "$essids" ]]; then @@ -167,37 +167,37 @@ wpa_supplicant_scan_info() { } set_rf_state() { - local INTERFACE=$1 state=$2 PROFILE=$3 + local INTERFACE="$1" state="$2" PROFILE="$3" - source $IFACE_DIR/$INTERFACE - [[ $PROFILE ]] && source $PROFILE_DIR/$PROFILE # profile overrides + source "$IFACE_DIR/$INTERFACE" + [[ -n "$PROFILE" ]] && source "$PROFILE_DIR/$PROFILE" # profile overrides [[ $RFKILL == "hard" ]] && report_fail "Cannot set state on hardware rfkill switch" - path=$(get_rf_path $INTERFACE $RFKILL_NAME) - case $state in + local path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") + case "$state" in up) - echo 1 > $path/state + echo 1 > "$path/state" ;; down) - echo 0 > $path/state + echo 0 > "$path/state" ;; esac } get_rf_path() { - local INTERFACE=$1 RFKILL_NAME=$2 + local INTERFACE="$1" RFKILL_NAME="$2" path - if [[ $RFKILL_NAME ]]; then + if [[ -n "$RFKILL_NAME" ]]; then for path in /sys/class/rfkill/*; do - if [[ "$(cat $path/name)" == $RFKILL_NAME ]]; then - echo $path + if [[ "$(cat "$path/name")" == "$RFKILL_NAME" ]]; then + echo "$path" return 0 fi done report_fail "no rfkill switch with name $RFKILL_NAME" else - path=/sys/class/net/$INTERFACE/rfkill - if [[ -d $path ]]; then - echo $path + path="/sys/class/net/$INTERFACE/rfkill" + if [[ -d "$path" ]]; then + echo "$path" return 0 fi report_fail "no rfkill switch available on interface $INTERFACE" @@ -205,19 +205,19 @@ get_rf_path() { } get_rf_state() { - local INTERFACE=$1 PROFILE=$2 - source $IFACE_DIR/$INTERFACE - [[ $PROFILE ]] && source $PROFILE_DIR/$PROFILE # profile overrides - path=$(get_rf_path $INTERFACE $RFKILL_NAME) - state=$(cat $path/state) + local INTERFACE="$1" PROFILE="$2" path state + source "$IFACE_DIR/$INTERFACE" + [[ -n "$PROFILE" ]] && source "$PROFILE_DIR/$PROFILE" # profile overrides + path=$(get_rf_path "$INTERFACE" "$RFKILL_NAME") + state=$(cat "$path/state") - case $state in + case "$state" in 0) echo "disabled";; 1) echo "enabled";; *) - echo $state;; + echo "$state";; esac } |