Project

General

Profile

Download (1.75 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
if [ "$2" == "inet" ]; then
4

    
5
	OLD_ROUTER=`/bin/cat /tmp/${1}_router`
6
	if [ "${OLD_ROUTER}" != "" ]; then
7
		echo "Removing states to old router ${OLD_ROUTER}" | logger -t ppp-linkup
8
		/sbin/pfctl -i $1 -k 0.0.0.0/0 -k ${OLD_ROUTER}/32
9
		/sbin/pfctl -i $1 -k ${OLD_ROUTER}/32 -k 0.0.0.0/0
10
	fi
11

    
12
	# let the configuration system know that the ipv4 has changed.
13
	/bin/echo $4 > /tmp/$1_router
14
	/bin/echo $3 > /tmp/$1_ip
15
	/usr/bin/touch /tmp/$1up
16

    
17
	ALLOWOVERRIDE=`/usr/bin/grep -c dnsallowoverride /conf/config.xml`
18
	if [ $ALLOWOVERRIDE -gt 0 ]; then
19
		# write nameservers to file
20
		if [ "`echo $6|grep -c dns1`" -gt 0 ]; then
21
			DNS1=`echo $6 |awk '{print $2}'`
22
			echo "$DNS1"> /var/etc/nameserver_$1
23
			/sbin/route change "$DNS1" $4
24
		fi
25
		if [ "`echo $7|grep -c dns2`" -gt 0 ]; then
26
			DNS2=`echo $7 |awk '{print $2}'`
27
			echo "$DNS2" >> /var/etc/nameserver_$1
28
			/sbin/route change "$DNS2" $4
29
		fi
30
		/usr/local/sbin/pfSctl -c 'service reload dns'
31
		/bin/sleep 1
32
	fi
33
fi
34

    
35
if [ "$2" == "inet6" ]; then
36
	# let the configuration system know that the ipv6 has changed.
37
	/bin/echo $4 |cut -d% -f1 > /tmp/$1_routerv6
38
	/bin/echo $3 |cut -d% -f1 > /tmp/$1_ipv6
39
	/usr/bin/touch /tmp/$1upv6
40

    
41
	ALLOWOVERRIDE=`/usr/bin/grep -c dnsallowoverride /conf/config.xml`
42
	if [ $ALLOWOVERRIDE -gt 0 ]; then
43
		# write nameservers to file
44
		if [ "`echo $6|grep -c dns1`" -gt 0 ]; then
45
			DNS1=`echo $6 |awk '{print $2}'`
46
			echo "$DNS1"> /var/etc/nameserver_v6$1
47
			/sbin/route change -inet6 "$DNS1" $4
48
		fi
49
		if [ "`echo $7|grep -c dns2`" -gt 0 ]; then
50
			DNS2=`echo $7 |awk '{print $2}'`
51
			echo "$DNS2" >> /var/etc/nameserver_v6$1
52
			/sbin/route change -inet6 "$DNS2" $4
53
		fi
54
		/usr/local/sbin/pfSctl -c 'service reload dns'
55
		/bin/sleep 1
56
	fi
57
fi
58

    
59
/usr/local/sbin/pfSctl -c "interface newip $1"
60
exit 0
(28-28/34)