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

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

Put it into logical brain ordering...

  • Property svn:executable set to *
File size: 1.4 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# Little hack to load the available functions in case we are running this as an
9# standalone script (for testing mostly).
10if [ -z "$exit_status" ]; then
11 grep -v 'exit $exit_status' /sbin/dhclient-script | eval
12fi
13
14. /etc/rc.subr
15
16: ${service_proxy_normal="NO"}
17: ${service_proxy_ileiden="NO"}
18: ${service_accesspoint="NO"}
19
20load_rc_config 'ileiden'
21
22update_pf_conf() {
23 if is_default_interface; then
24 new_ext_if_gw=`route -n get default | awk '/gateway/ {print $2}'`
25 if [ -n "$new_ext_if_gw" ]; then
26 if [ -a "$new_ext_if_gw" != "$ext_if_gw" ]; then
27 info "Reloading PF firewall to load new ext_if_gw=$ext_if_gw"
28 { grep -v '^ext_if_gw=' $rc_conf_running; echo "ext_if_gw=$new_ext_if_gw"; } > $rc_conf_running
29 /etc/rc.d/pf reload
30 fi
31 fi
32 fi
33
34 # Make sure not to nuke the default route on an ileiden proxy,
35 # as it will rendering it usefull
36 checkyesno "service_proxy_ileiden" && return
37
38 if checkyesno "service_proxy_normal" && checkyesno "service_accesspoint"; then
39 warn "Removing default route as machine is marked as service_proxy AND service_accesspoint"
40 route -q del default
41 fi
42}
43
44reason=${reason:-$FORCE}
45
46case $reason in
47 BOUND|RENEW|REBIND|REBOOT)
48 update_pf_conf
49 ;;
50 TIMEOUT)
51 update_pf_conf
52 ;;
53esac
54
Note: See TracBrowser for help on using the repository browser.