Commit d8b7ce43 authored by James Rayner's avatar James Rayner
Browse files

Added initial rfkill support

 Added some extra debug points
 Directed debug out to stderr, as debug messages were being used as
output from find_essid.
parent 0803c7a8
......@@ -22,14 +22,41 @@ wireless_up() {
. "$SUBR_DIR/8021x"
. "$SUBR_DIR/wireless"
# If rfkill is specified, enable device.
# 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
echo 1 > ${path}/state
else
path=/sys/class/net/$INTERFACE/rfkill
if [[ ! -d $path ]]; then
report_fail "no rfkill switch available on interface $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
......@@ -234,6 +261,22 @@ wireless_down() {
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
fi
}
# Returns status of profile - is it still functional?
......@@ -250,3 +293,4 @@ wireless_status() {
wireless_$1 "$2" "$3"
exit $?
# vim: set ts=4 et sw=4:
......@@ -12,7 +12,7 @@
PROFILE_DIR="/etc/network.d/"
HOOKS_DIR="/usr/lib/network/hooks/"
USERHOOKS_DIR="$PROFILE_DIR/hooks/"
IFACE_DIR="$PROFILE/interfaces/"
IFACE_DIR="$PROFILE_DIR/interfaces/"
SUBR_DIR="/usr/lib/network/"
CONN_DIR="${SUBR_DIR}/connections/"
STATE_DIR="/var/run/network/"
......@@ -35,7 +35,7 @@ function report_notify {
}
function report_debug {
checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*"
checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*" >&2
}
function report_try {
......@@ -121,4 +121,3 @@ function load_hooks() {
load_hooks
......@@ -13,12 +13,15 @@ load_profile()
report_fail "Profile \"$1\" does not exist"
return 1
fi
report_debug "Loading profile $1"
. "$PROFILE_DIR/$1"
report_debug "Configuring interface $INTERFACE"
if [[ -z "$INTERFACE" ]]; then
report_fail "Profile missing an interface to configure"
return 1
fi
if [[ -f "$IFACE_DIR/$INTERFACE" ]]; then
report_debug "Interface level configuration enabled: $IFACE_DIR/$INTERFACE"
. "$IFACE_DIR/$INTERFACE"
. "$PROFILE_DIR/$1" # we want profile settings to override, so need to source profile again
fi
......
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