summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2014-02-25 14:50:28 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2014-02-25 15:21:03 +0100
commit33c6ca7f01a36551ca436a96aafd1bf639bcea2f (patch)
treeaff712316fda54b67eed9dadd98cfd74da3f3f49 /src
parent3dc6d75f5fa4813fe5c998b13582912fffd88159 (diff)
downloadnetctl-33c6ca7f01a36551ca436a96aafd1bf639bcea2f.tar.gz
netctl-33c6ca7f01a36551ca436a96aafd1bf639bcea2f.tar.xz
Code style and output improvements
Now a bit more verbose when useful.
Diffstat (limited to 'src')
-rw-r--r--src/lib/connections/bond2
-rw-r--r--src/lib/connections/ethernet2
-rw-r--r--src/lib/wpa21
-rwxr-xr-xsrc/wifi-menu2
4 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/connections/bond b/src/lib/connections/bond
index af95753..c22fc82 100644
--- a/src/lib/connections/bond
+++ b/src/lib/connections/bond
@@ -10,7 +10,7 @@ bond_up() {
report_error "Interface '$Interface' already exists"
return 1
else
- ip link add dev "$Interface" type bond
+ ip link add name "$Interface" type bond
fi
bring_interface_up "$Interface"
diff --git a/src/lib/connections/ethernet b/src/lib/connections/ethernet
index dfd0117..3db69a0 100644
--- a/src/lib/connections/ethernet
+++ b/src/lib/connections/ethernet
@@ -22,7 +22,7 @@ ethernet_up() {
if ! is_yes "${SkipNoCarrier:-no}"; then
# Some cards are plain slow to come up. Don't fail immediately.
if ! timeout_wait "${TimeoutCarrier:-5}" '(( $(< "/sys/class/net/$Interface/carrier") ))'; then
- report_error "No connection on interface '$Interface'"
+ report_error "No connection found on interface '$Interface' (timeout)"
bring_interface_down "$Interface"
return 1
fi
diff --git a/src/lib/wpa b/src/lib/wpa
index ff869db..8804f34 100644
--- a/src/lib/wpa
+++ b/src/lib/wpa
@@ -67,6 +67,11 @@ wpa_start() {
local interface=$1 driver=$2 configuration=$3
local pidfile="/run/wpa_supplicant_$interface.pid"
+ if ! type wpa_supplicant &> /dev/null; then
+ report_error "You need to install 'wpa_supplicant'"
+ return 127
+ fi
+
if [[ $configuration ]]; then
configuration="-c$configuration"
else
@@ -78,7 +83,7 @@ wpa_start() {
"$configuration" $WPAOptions
# Wait up to one second for the pid file to appear
- if ! timeout_wait 1 '[[ -f "$pidfile" ]]'; then
+ if ! timeout_wait 1 '[[ -f $pidfile ]]'; then
# Remove the configuration file if it was generated
configuration="$STATE_DIR/wpa_supplicant_$interface.conf"
[[ -f $configuration && -O $configuration ]] && rm -f "$configuration"
@@ -145,7 +150,7 @@ wpa_supplicant_scan() {
(( spawned_wpa == 1 )) && wpa_stop "$interface"
# File of 0 length: no ssid's
- if [[ ! -s "$essids" ]]; then
+ if [[ ! -s $essids ]]; then
rm -f "$essids"
return 1
fi
@@ -172,11 +177,11 @@ wpa_quote() {
## Hex: 737472696e67 -> string
wpa_unquote() {
local string="$1"
- if [[ ${string:0:1} == '"' && ${string:(-1)} == '"' ]]; then
+ if [[ $string == \"*\" ]]; then
printf "%s" "${string:1:-1}"
- elif [[ "$string" =~ ^([[:xdigit:]]{2})+$ ]]; then
- while [[ -n "$string" ]]; do
- printf "\x"${string:0:2}
+ elif [[ $string == +([[:xdigit:]][[:xdigit:]]) ]]; then
+ while [[ $string ]]; do
+ printf "\x${string:0:2}"
string=${string:2}
done
else
@@ -218,7 +223,7 @@ wpa_make_config_block() {
wep)
echo "key_mgmt=NONE"
echo "wep_tx_keyidx=0"
- if (( ${#Key} % 2 == 0 )) && [[ "$Key" = +([[:xdigit:]]) ]]; then
+ if [[ $Key == +([[:xdigit:]][[:xdigit:]]) ]]; then
echo "wep_key0=$Key"
else
echo "wep_key0=$(wpa_quote "$Key")"
@@ -226,7 +231,7 @@ wpa_make_config_block() {
;;
wpa)
echo "proto=RSN WPA"
- if [[ "${#Key}" -eq 64 && "$Key" = +([[:xdigit:]]) ]]; then
+ if [[ "${#Key}" -eq 64 && $Key == +([[:xdigit:]]) ]]; then
echo "psk=$Key"
else
echo "psk=$(wpa_quote "$Key")"
diff --git a/src/wifi-menu b/src/wifi-menu
index 455cdc9..0323e51 100755
--- a/src/wifi-menu
+++ b/src/wifi-menu
@@ -98,7 +98,7 @@ confirm_profile()
{
local msg="Enter a name for the new profile\n"
PROFILE=$(dialog --inputbox "$msg" 10 50 "$PROFILE" --stdout) || return $?
- if [[ $PROFILE = */* ]]; then
+ if [[ "$PROFILE" = */* ]]; then
PROFILE=${PROFILE//\//_}
confirm_profile
elif [[ -e "$PROFILE_DIR/$PROFILE" ]]; then