diff options
Diffstat (limited to 'src/connections')
-rw-r--r-- | src/connections/ethernet | 14 | ||||
-rw-r--r-- | src/connections/ethernet-iproute | 11 | ||||
-rw-r--r-- | src/connections/wireless | 18 |
3 files changed, 23 insertions, 20 deletions
diff --git a/src/connections/ethernet b/src/connections/ethernet index 22405ad..5985ce5 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -4,8 +4,8 @@ ethernet_up() { load_profile "$1" - if [[ ! -e /sys/class/net/"$INTERFACE" ]]; then - if ! echo "$INTERFACE"| fgrep ":"; then + if [[ ! -e "/sys/class/net/$INTERFACE" ]]; then + if ! echo "$INTERFACE" | fgrep -q ":"; then report_fail "interface $INTERFACE does not exist" return 1 fi @@ -21,7 +21,7 @@ ethernet_up() { fi if checkyesno "${AUTH8021X:-no}"; then - . "${SUBR_DIR}"/8021x + . "$SUBR_DIR/8021x" [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired" report_debug ethernet_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS" @@ -49,7 +49,7 @@ ethernet_up() { fi else # Clear remaining pid files. - rm -f "/var/run/dhcpcd-${INTERFACE}".{pid,cache} >/dev/null 2>&1 + rm -f "/var/run/dhcpcd-$INTERFACE".{pid,cache} >/dev/null 2>&1 # If using own dns, tell dhcpcd to NOT replace resolv.conf [[ -n "$DNS1" || -n "$DNS" ]] && DHCP_OPTIONS="-C resolv.conf $DHCP_OPTIONS" # Start dhcpcd @@ -86,7 +86,7 @@ ethernet_up() { fi ;; *) - report_fail "IP=\"\" must be either 'dhcp' or 'static'." + report_fail "IP must be either 'dhcp' or 'static'." return 1 ;; esac @@ -95,13 +95,13 @@ ethernet_up() { if [[ -n "$HOSTNAME" ]]; then report_debug ethernet_up hostname "$HOSTNAME" if ! hostname "$HOSTNAME"; then - report_fail "Setting hostname failed." + report_fail "Setting hostname $HOSTNAME failed." return 1 fi fi # Generate a new resolv.conf - if [[ -n "$DNS1" ]] || [[ -n "$DNS" ]]; then + if [[ -n "$DNS1" || -n "$DNS" ]]; then : >/etc/resolv.conf [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc/resolv.conf diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute index 385e128..eedda15 100644 --- a/src/connections/ethernet-iproute +++ b/src/connections/ethernet-iproute @@ -20,12 +20,13 @@ ethernet_up() { report_debug ethernet_iproute_up ifup set_interface up "$INTERFACE" + if ip link show dev "$INTERFACE" | fgrep -q "NO-CARRIER"; then report_iproute "No connection" fi if checkyesno "${AUTH8021X:-no}"; then - . "${SUBR_DIR}/8021x" + . "$SUBR_DIR/8021x" [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired" @@ -47,7 +48,7 @@ ethernet_up() { case "$IP" in dhcp) # Clear remaining pid files. - rm -f "/var/run/dhcpcd-${INTERFACE}".{pid,cache} >/dev/null 2>&1 + rm -f "/var/run/dhcpcd-$INTERFACE".{pid,cache} >/dev/null 2>&1 # If using own dns, tell dhcpcd to NOT replace resolv.conf [[ -n "$DNS" ]] && DHCP_OPTIONS="-C resolv.conf $DHCP_OPTIONS" @@ -61,7 +62,7 @@ ethernet_up() { static) if [[ -n "$ADDR" ]]; then report_debug ethernet_iproute_up ip addr add "$ADDR/24" brd + dev "$INTERFACE" - if ! ip addr add "${ADDR}/24" brd + dev "$INTERFACE"; then + if ! ip addr add "$ADDR/24" brd + dev "$INTERFACE"; then report_iproute "Could not configure interface" fi fi @@ -73,7 +74,7 @@ ethernet_up() { fi ;; *) - report_iproute "Profile error: IP must be either 'dhcp' or 'static'" + report_iproute "IP must be either 'dhcp' or 'static'" ;; esac @@ -91,7 +92,7 @@ ethernet_up() { if [[ -n "$HOSTNAME" ]]; then report_debug ethernet_iproute_up hostname "$HOSTNAME" if ! hostname "$HOSTNAME"; then - report_iproute "Cannot set hostname" + report_iproute "Cannot set hostname to $HOSTNAME" fi fi diff --git a/src/connections/wireless b/src/connections/wireless index d341e99..2951cdd 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -19,8 +19,8 @@ wireless_up() { load_profile "$1" [[ -n "$2" ]] && ESSID="$2" # JP: use the literal ESSID (though currently we only interpret wireless-dbus ESSIDs as regexps) - . "${SUBR_DIR}/8021x" - . "${SUBR_DIR}/wireless" + . "$SUBR_DIR/8021x" + . "$SUBR_DIR/wireless" # If rfkill is specified, enable device. if [[ -n "$RFKILL_NAME" ]]; then @@ -33,7 +33,7 @@ wireless_up() { fi # Check if interface exists - if [[ ! -e /sys/class/net/"$INTERFACE" ]]; then + if [[ ! -e "/sys/class/net/$INTERFACE" ]]; then if ! echo "$INTERFACE" | fgrep -q ":"; then report_fail "interface $INTERFACE does not exist" return 1 @@ -79,7 +79,7 @@ wireless_up() { fi # Manually set iwconfig options - if [[ "$IWCONFIG" ]]; then + if [[ -n "$IWCONFIG" ]]; then report_debug wireless_up iwconfig "$INTERFACE" $IWCONFIG iwconfig "$INTERFACE" $IWCONFIG fi @@ -113,7 +113,7 @@ wireless_up() { fi report_debug wireless_up iwconfig "$INTERFACE" $WEP_OPTS - if ! eval iwconfig $INTERFACE $WEP_OPTS; then + if ! eval "iwconfig \"$INTERFACE\" $WEP_OPTS"; then report_fail "Could not set wireless configuration." return 1 fi @@ -149,6 +149,8 @@ wireless_up() { # Generate configuration if [[ "${#KEY}" -eq 64 ]]; then echo -e "network={ \nssid=\"$ESSID\" \npsk=$KEY \n}">> "$WPA_CONF/wpa.conf" + # JP: formerly I had { \nssid=\"$ESSID\" \nproto=WPA \nkey_mgmt=WPA-PSK \npsk=$KEY \n} + # JP: is what's above better? elif ! echo "$KEY" | wpa_passphrase "$ESSID" >> "$WPA_CONF/wpa.conf"; then report_fail "Configuration generation failed." cat "$WPA_CONF/wpa.conf" >&2 @@ -169,7 +171,7 @@ wireless_up() { fi ;; wpa-config) - . "${SUBR_DIR}/8021x" + . "$SUBR_DIR/8021x" [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext" report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS" @@ -187,7 +189,7 @@ wireless_up() { conn=ethernet checkyesno "${IPROUTE:-no}" && conn=ethernet-iproute - if ! "${CONN_DIR}/$conn" up "$1"; then + if ! "$CONN_DIR/$conn" up "$1"; then wireless_down "$1" YES return 1 fi @@ -196,7 +198,7 @@ wireless_up() { wireless_down() { local PROFILE="$1" NOETHERNETDOWN="$2" load_profile "$PROFILE" - . "${SUBR_DIR}/8021x" + . "$SUBR_DIR/8021x" if ! checkyesno "$NOETHERNETDOWN"; then conn=ethernet checkyesno "${IPROUTE:-no}" && conn=ethernet-iproute |