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

#
# 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 -6 route show default)
GW=$(echo ${GW#*via} | cut -d ' ' -f 1)
if [ -n "$GW" ]; then
(
# subshell for new trap context
ping -6 -q -c 1 -w 1 $GW >/dev/null
MAC=$(ip -6 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
GW6_IP=$GW
GW6_MAC=$MAC
EOF
# if changed:
cmp -s /tmp/guestwifi-ipv6 $TMP || {
mv $TMP /tmp/guestwifi-ipv6
TMP=
(
. /lib/wifi/delos-wifi/20_delos-guest-wifi
set_delos_guestwifi
)
}
) else
# if removed:
rm /tmp/guestwifi-ipv6 2>/dev/null && {
. /lib/wifi/delos-wifi/20_delos-guest-wifi
set_delos_guestwifi
}
fi