summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Pryor <profjim@jimpryor.net>2009-09-14 05:43:34 +0200
committerJames Rayner <james@archlinux.org>2009-09-14 08:22:11 +0200
commit67f1b8fae53ebe22ad1a0557c0d7a1371b96cb0b (patch)
tree76a0ad11c1df8272d0815a9c6c8398953f4effa0 /src
parent820d9295b51e427f3e17c9e83227a127ef9b7631 (diff)
downloadnetctl-67f1b8fae53ebe22ad1a0557c0d7a1371b96cb0b.tar.gz
netctl-67f1b8fae53ebe22ad1a0557c0d7a1371b96cb0b.tar.xz
Tweaks while merging
* added various quotes * made some vars local * tweaked some [[ ]]s, including one broken one in netcfg-menu * s/ra0/$INTERFACE/ in ethernet-iproute and wireless Signed-off-by: Jim Pryor <profjim@jimpryor.net>
Diffstat (limited to 'src')
-rw-r--r--src/connections/ethernet-iproute2
-rw-r--r--src/connections/wireless20
-rw-r--r--src/globals1
-rw-r--r--src/netcfg-menu2
-rw-r--r--src/network3
-rw-r--r--src/wireless50
6 files changed, 40 insertions, 38 deletions
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
}