Commit 33c6ca7f authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Code style and output improvements

Now a bit more verbose when useful.
parent 3dc6d75f
......@@ -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"
......
......@@ -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
......
......@@ -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")"
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment