source: hybrid/branches/releng-9.0/nanobsd/files/etc/dhclient-exit-hooks@ 10609

Last change on this file since 10609 was 10609, checked in by rick, 13 years ago

The hack is flawed because of the lack of setting all kind of variables which
dhclient does. Removing it to avoid confusion.

Related-To: nodefactory#129

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/bin/sh -
2#
3# An normal proxy should not have an defaultrouter configured, as all calls to
4# the outside world are handled via PF redirects.
5#
6# Rick van der Zwet <rick@wirelessleiden.nl>
7
8. /etc/rc.subr
9
10: ${service_proxy_normal="NO"}
11: ${service_proxy_ileiden="NO"}
12: ${service_accesspoint="NO"}
13
14load_rc_config 'ileiden'
15
16update_pf_conf() {
17 $LOGGER "reason: $reason"
18 if is_default_interface 2>/dev/null; then
19 $LOGGER "is_default_interface: TRUE"
20 new_ext_if_gw=`route -n get default 2>/dev/null | awk '/gateway/ {print $2}'`
21 $LOGGER "prev default gateway: $ext_if_gw"
22 $LOGGER "curr default gateway: $new_ext_if_gw"
23 if [ -n "$new_ext_if_gw" -a "$new_ext_if_gw" != "$ext_if_gw" ]; then
24 $LOGGER "Reloading PF firewall to load new ext_if_gw=$new_ext_if_gw"
25 { grep -v '^ext_if_gw=' $rc_conf_running; echo "ext_if_gw=$new_ext_if_gw"; } > $rc_conf_running
26 $LOGGER "`/etc/rc.d/pf reload 2>&1`"
27 fi
28 else
29 $LOGGER "is_default_interface: FALSE"
30 fi
31
32 # Make sure not to nuke the default route on an ileiden proxy,
33 # as it will rendering it usefull
34 checkyesno "service_proxy_ileiden" && return
35
36 if [ -n "$new_ext_if_gw" ] && checkyesno "service_proxy_normal" && checkyesno "service_accesspoint"; then
37 $LOGGER "Removing default route as machine is marked as service_proxy AND service_accesspoint"
38 $LOGGER "`route -q del default 2>&1`"
39 fi
40}
41
42reason=${reason:-${REASON:-"BOUND"}}
43case $reason in
44 BOUND|RENEW|REBIND|REBOOT)
45 update_pf_conf
46 ;;
47 TIMEOUT)
48 update_pf_conf
49 ;;
50esac
51
Note: See TracBrowser for help on using the repository browser.