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

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

We are going todo musical chairs over here to auto-magically reload the pf
firewall allowing to make the normal proxy work properly (saves us from
specifing the gateway standardly).

Related-To: nodefactory#129

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