You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1022 B
Bash
45 lines
1022 B
Bash
#!/bin/sh
|
|
|
|
. /lib/functions.sh
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
logger() {
|
|
command logger -t wifi-eventd "$@"
|
|
}
|
|
|
|
ssid_of_device() {
|
|
local DEVICE=${1}
|
|
ubus call uci state "{\"config\":\"wireless\",\"type\":\"wifi-iface\",\"match\":{\"ifname\":\"${DEVICE}\"}}" | jsonfilter -e '$.values.*.ssid'
|
|
}
|
|
|
|
iw_event() {
|
|
local a
|
|
acfg_tool -e | while : ;do
|
|
read a
|
|
MAC=$(echo ${a} | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tr [a-z] [A-Z])
|
|
case "$a" in
|
|
*"Event disassoc"*|\
|
|
*"Event deauth"*)
|
|
if [ "${MAC}" != "FF:FF:FF:FF:FF:FF" ]; then
|
|
echo " del station"
|
|
/usr/sbin/update_wifi_client_list.sh disassoc "${MAC}"
|
|
fi
|
|
;;
|
|
*"Event assoc"*)
|
|
if [ "${MAC}" != "FF:FF:FF:FF:FF:FF" ]; then
|
|
echo " new station"
|
|
DEVICE=$(echo ${a} | awk -F: '{print $1}')
|
|
RADIO=${DEVICE:3:1}
|
|
SSID=$(ssid_of_device ${DEVICE})
|
|
/usr/sbin/update_wifi_client_list.sh assoc "${MAC}" "${RADIO}" "${SSID}"
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
trap 'trap - TERM INT; kill 0; exit' TERM INT
|
|
iw_event &
|
|
wait
|
|
exit 0
|