# dhclient-exit-hook: switchgate-helper
RUN="yes"
SWITCHGATE="/usr/local/sbin/switchgate"
if [ "$RUN" = "yes" ]; then
# ipv4 or ipv6?
if [ -z "$(echo "$reason" | sed -e "s/^.*6$//")" ]; then
IF_FILENAME="dhcp6.${interface}"
IPV="IPv6"
else
IF_FILENAME="dhcp.${interface}"
IPV="IPv4"
fi
# get writeable tmp dir from switchgate
SWITCHGATE_TMPDIR="$("$SWITCHGATE" -C)"
if [ $? -ne 0 ]; then
echo -e "Error: Failed to query switchgate:\n\n$SWITCHGATE_TMPDIR"
exit 1
elif [ -z "$SWITCHGATE_TMPDIR" ]; then
echo "Error: No writeable dir from switchgate received. Please check."
exit 1
fi
case "$reason" in
BOUND|RENEW|REBIND|REBOOT|BOUND6|RENEW6|REBIND6|REBOOT6)
# check there is a gateway given
if [ -z "$new_routers" ]; then
echo "No $IPV gateway supplied from DHCP server."
# remove the gw file
if [ -f "$SWITCHGATE_TMPDIR/$IF_FILENAME" ]; then
rm "$SWITCHGATE_TMPDIR/$IF_FILENAME"
fi
exit 0
fi
# create writeable dir if not already existing
if [ ! -d "$SWITCHGATE_TMPDIR" ]; then
mkdir "$SWITCHGATE_TMPDIR"
fi
echo "Adding DHCP supplied gateways to the list of gateways for switchgate: $new_routers"
# Register switchgate routers
echo "$new_routers" | sed -e "s/ /\n/g" > "$SWITCHGATE_TMPDIR/$IF_FILENAME"
;;
*)
# remove the gw file
if [ -f "$SWITCHGATE_TMPDIR/$IF_FILENAME" ]; then
rm "$SWITCHGATE_TMPDIR/$IF_FILENAME"
fi
exit 0
;;
esac
fi
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>