diff options
Diffstat (limited to 'src/connections')
-rw-r--r-- | src/connections/ethernet | 19 | ||||
-rw-r--r-- | src/connections/wireless | 73 |
2 files changed, 18 insertions, 74 deletions
diff --git a/src/connections/ethernet b/src/connections/ethernet index dd07667..5414c69 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -9,7 +9,7 @@ ethernet_up() { report_fail "interface $INTERFACE does not exist" return 1 fi - fi + fi report_debug ethernet_up ifup set_interface up-old "$INTERFACE" @@ -20,7 +20,7 @@ ethernet_up() { return 1 fi - if checkyesno "${AUTH8021X:-no}"; then + if checkyesno "${AUTH8021X:-no}"; then . "$SUBR_DIR/8021x" [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired" @@ -35,7 +35,7 @@ ethernet_up() { set_interface forcedown-old "$INTERFACE" report_fail "WPA Authentication/Association Failed" return 1 - fi + fi fi case "$IP" in @@ -48,7 +48,7 @@ ethernet_up() { return 1 fi else - # Clear remaining pid files. + # Clear remaining pid files. 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" @@ -58,10 +58,10 @@ ethernet_up() { if [[ "$PIPESTATUS" -ne 0 ]]; then report_fail "DHCP IP lease attempt failed." return 1 - fi + fi fi if [[ -n "$IFOPTS" ]]; then - report_debug ethernet_up ifup $IFOPTS + report_debug ethernet_up ifup $IFOPTS ifconfig "$INTERFACE" $IFOPTS fi ;; @@ -82,7 +82,7 @@ ethernet_up() { set_interface forcedown-old "$INTERFACE" report_fail "Adding gateway $GATEWAY failed." return 1 - fi + fi fi ;; *) @@ -103,7 +103,7 @@ ethernet_up() { # Generate a new resolv.conf if [[ -n "$DNS1" || -n "$DNS" ]]; then - : >/etc/resolv.conf + : >/etc/resolv.conf [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc/resolv.conf [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc/resolv.conf [[ -n "$DNS1" ]] && echo "nameserver $DNS1" >>/etc/resolv.conf @@ -141,7 +141,7 @@ ethernet_down() { fi ;; esac - + report_debug ethernet_down ifdown # ignore quirk nodown---is that appropriate? # this adds a flush call as well---is that appropriate? @@ -158,3 +158,4 @@ ethernet_status() { ethernet_$1 "$2" exit $? # vim: set ts=4 et sw=4: + diff --git a/src/connections/wireless b/src/connections/wireless index 1874b55..29e4112 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -2,18 +2,6 @@ . /usr/lib/network/network -rfkill_from_name() { - local name=$1 - for rfkill in /sys/class/rfkill/*; do - if [[ "$(cat $rfkill/name)" == $name ]]; then - echo $rfkill - return 0 - fi - done - echo "none" - return 1 -} - wireless_up() { load_profile "$1" @@ -22,41 +10,15 @@ wireless_up() { . "$SUBR_DIR/8021x" . "$SUBR_DIR/wireless" - - # Handle wireless kill switches if [[ $RFKILL ]]; then - report_debug "rfkill support enabled: $RFKILL" - if [[ -n "$RFKILL_NAME" ]]; then - path=$(rfkill_from_name $RFKILL_NAME) - if [[ $? -ne 0 ]]; then - report_fail "no rfkill switch with the name $RFKILL_NAME"; - fi - else - path=/sys/class/net/$INTERFACE/rfkill - if [[ ! -d $path ]]; then - report_fail "no rfkill switch available on interface $INTERFACE" + 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" fi fi - - - case $RFKILL in - soft) - echo 1 > ${path}/state # Soft switch, so enable - sleep 1 - report_debug "Enabled RFKILL on $path" - ;; - hard) - state=$(cat ${path}/state) - case $state in - 0) - report_fail "Card disabled";; - 1) - true;; - *) - report_fail "Unknown state: $state";; - esac - ;; - esac fi # Check if interface exists @@ -252,30 +214,11 @@ wireless_down() { # this adds a flush call as well---is that appropriate? set_interface down-old "$INTERFACE" - # If rfkill is specified, disable device. - if [[ -n "$RFKILL_NAME" ]]; then - path=$(rfkill_from_name "$RFKILL_NAME") - if [[ $? -ne 0 ]]; then - report_fail "no rfkill switch with the name $RFKILL_NAME"; - fi - echo 0 > "${path}/state" - fi - # Handle wireless kill switches # Any reason why a hardware switch should be considered on interface down? if [[ $RFKILL == "soft" ]]; then - if [[ -n $RFKILL_NAME ]]; then - path=$(rfkill_from_name $RFKILL_NAME) - if [[ $? -ne 0 ]]; then - report_fail "no rfkill switch with the name $RFKILL_NAME"; - fi - else - path=/sys/class/net/$INTERFACE/rfkill - if [[ ! -d $path ]]; then - report_fail "no rfkill switch available on interface $INTERFACE" - fi - fi - echo 0 > ${path}/state # Soft switch, so disable + . "$SUBR_DIR/wireless" + set_rf_state $INTERFACE down fi } |