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.
43 lines
936 B
Plaintext
43 lines
936 B
Plaintext
#
|
|
# Copyright (C) 2018 devolo AG
|
|
#
|
|
|
|
# DHCP event happened. it could have added/deleted the default route to the gateway
|
|
# let's look it up and trigger rewrite of guest wifi filter tables when it changed
|
|
|
|
# get the first default gateway IP address
|
|
GW=$(ip -4 route show default)
|
|
GW=$(echo ${GW#*via} | cut -d ' ' -f 1)
|
|
|
|
if [ -n "$GW" ]; then
|
|
(
|
|
# subshell for new trap context
|
|
|
|
ping -4 -q -c 1 -w 1 $GW >/dev/null
|
|
MAC=$(ip -4 neigh show to $GW)
|
|
MAC=$(echo ${MAC#*lladdr} | cut -d ' ' -f 1)
|
|
|
|
TMP=
|
|
trap '[ -n "$TMP" ] && rm -f "$TMP"; TMP=' EXIT HUP INT QUIT TERM
|
|
TMP=$(mktemp)
|
|
cat >$TMP <<-EOF
|
|
GW4_IP=$GW
|
|
GW4_MAC=$MAC
|
|
EOF
|
|
# if changed:
|
|
cmp -s /tmp/guestwifi-ipv4 $TMP || {
|
|
mv $TMP /tmp/guestwifi-ipv4
|
|
TMP=
|
|
(
|
|
. /lib/wifi/delos-wifi/20_delos-guest-wifi
|
|
set_delos_guestwifi
|
|
)
|
|
}
|
|
) else
|
|
# if removed:
|
|
rm /tmp/guestwifi-ipv4 2>/dev/null && {
|
|
. /lib/wifi/delos-wifi/20_delos-guest-wifi
|
|
set_delos_guestwifi
|
|
}
|
|
fi
|