diff options
-rw-r--r-- | src/connections/ethernet | 7 | ||||
-rw-r--r-- | src/connections/ethernet-iproute | 7 | ||||
-rw-r--r-- | src/connections/wireless | 45 |
3 files changed, 58 insertions, 1 deletions
diff --git a/src/connections/ethernet b/src/connections/ethernet index e24e9f5..38b341c 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -124,6 +124,13 @@ ethernet_down() { esac } +# Returns status of profile - is it still functional? +ethernet_status() { + if ! ip link show dev ra0|grep -q "state UP"; then + return 1 + fi +} + ethernet_$1 $2 exit $? # vim: set ts=4 et sw=4: diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute index 1a4a6e4..a6c4804 100644 --- a/src/connections/ethernet-iproute +++ b/src/connections/ethernet-iproute @@ -112,6 +112,13 @@ ethernet_down() { } +# Returns status of profile - is it still functional? +ethernet_status() { + if ! ip link show dev ra0|grep -q "state UP"; then + return 1 + fi +} + ethernet_$1 $2 exit $? # vim: set ts=4 et sw=4: diff --git a/src/connections/wireless b/src/connections/wireless index 8b43ed1..7394a20 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -1,12 +1,34 @@ #! /bin/bash . /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 . ${SUBR_DIR}/8021x . ${SUBR_DIR}/wireless + # If rfkill is specified, enable device. + if [[ -n "$RFKILL_NAME" ]]; then + path=$(rfkill_from_name $RFKILL_NAME) + if [[ $? -ne 0 ]]; then + err_append "no rfkill switch with the name $RFKILL_NAME"; + fi + echo 1 > ${path}/state + fi + # Check if interface exists if [[ ! -e /sys/class/net/"$INTERFACE" ]]; then if ! echo "$INTERFACE"|grep ":"; then @@ -17,7 +39,7 @@ wireless_up() { # Kill any lingering wpa_supplicants. stop_wpa $INTERFACE - + # Most drivers (mac80211) need mode set before device is brought up # Drivers generally default to managed, but set this to be sure. if [[ "$(iwgetid -sm $INTERFACE)" -ne "Managed" ]]; then @@ -117,6 +139,27 @@ wireless_down() { [[ "$SECURITY" == "wpa" ]] && rm -f "/tmp/wpa.${1// /}" # remove wpa config iwconfig $INTERFACE essid off key off &> /dev/null ifconfig $INTERFACE down + + # If rfkill is specified, disable device. + if [[ -n "$RFKILL_NAME" ]]; then + path=$(rfkill_from_name $RFKILL_NAME) + if [[ $? -ne 0 ]]; then + err_append "no rfkill switch with the name $RFKILL_NAME"; + fi + echo 0 > ${path}/state + fi + +} + +# Returns status of profile - is it still functional? +wireless_status() { + load_profile $1 + if [[ "$(iwgetid -r)" -ne $ESSID ]]; then + return 1 + elif ! ip link show dev ra0|grep -q "state UP"; then + return 1 + fi + } wireless_$1 $2 |