]>
Commit | Line | Data |
---|---|---|
bf7c473f MT |
1 | #!/bin/sh |
2 | ######################################################################## | |
3 | # Begin $network_devices/red/update | |
4 | # | |
5 | # Description : Update red interface | |
6 | # | |
7 | # Authors : Michael Tremer - mitch@ipfire.org | |
8 | # | |
9 | # Version : 01.00 | |
10 | # | |
11 | # Notes : update the settings if red goes up or down | |
12 | # | |
13 | ######################################################################## | |
14 | ||
15 | eval $(/usr/local/bin/readhash /var/ipfire/vpn/settings) | |
16 | eval $(/usr/local/bin/readhash /var/ipfire/dhcp/settings) | |
17 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) | |
18 | eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) | |
19 | ||
20 | if [ ! -e /var/lock/red.lock ]; then | |
21 | touch /var/lock/red.lock | |
22 | logger -p local0.info -t red[$$] "$0 locking for $$" | |
23 | else | |
24 | count=0 | |
25 | while [ ! $count = 5 ]; do | |
26 | sleep 3 | |
27 | if [ ! -e /var/lock/red.lock ]; then | |
28 | break | |
29 | else | |
30 | /usr/bin/logger -p local0.info -t red[$$] "$0 $$ waiting unlock" | |
31 | fi | |
32 | ((++count)) | |
33 | done | |
34 | fi | |
35 | ||
36 | IFACE=`cat /var/ipfire/red/iface 2>/dev/null | tr -d '\012'` | |
37 | REMOTE=`cat /var/ipfire/red/remote-ipaddress 2>/dev/null | tr -d '\012'` | |
38 | ||
39 | ### DNS Settings | |
40 | DNS1=`cat /var/ipfire/red/dns1 2>/dev/null | tr -d '\012'` | |
41 | DNS2=`cat /var/ipfire/red/dns2 2>/dev/null | tr -d '\012'` | |
42 | echo > /var/ipfire/red/resolv.conf #clear it | |
43 | [ "$DNS1" != "" ] && echo "nameserver $DNS1" > /var/ipfire/red/resolv.conf | |
44 | [ "$DNS2" != "" ] && echo "nameserver $DNS2" >> /var/ipfire/red/resolv.conf | |
45 | ||
46 | ### Restart DNSMASQ | |
47 | killall -KILL dnsmasq 2> /dev/null | |
48 | sleep 1 | |
49 | ARGS="" | |
50 | [ "$DOMAIN_NAME_GREEN" ] && ARGS="-s $DOMAIN_NAME_GREEN" | |
51 | if [ -e "/var/ipfire/red/dial-on-demand" -a "$DIALONDEMANDDNS" == "on" -a ! -e "/var/ipfire/red/active" ]; then | |
52 | /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS -r /var/ipfire/ppp/fake-resolv.conf | |
53 | else | |
54 | /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS -r /var/ipfire/red/resolv.conf | |
55 | fi | |
56 | unset ARGS | |
57 | ||
58 | ### Reset default route to ippp0 for dial on demand | |
59 | if [ -e "/var/ipfire/red/dial-on-demand" -a "$TYPE" == "isdn" -a ! -e "/var/ipfire/red/active" ]; then | |
60 | ip route del default 2> /dev/null | |
61 | if [ ! -z "$REMOTE" ]; then | |
62 | ip route add default gw $REMOTE 2> /dev/null | |
63 | else | |
64 | ip route add default dev ippp0 2> /dev/null | |
65 | fi | |
66 | fi | |
67 | ||
68 | if ( echo $0 | /bin/grep -q 'dhcpcd.exe' ); then | |
69 | eval $(/usr/local/bin/readhash "$1") | |
70 | case "$2" in | |
71 | up) | |
72 | logger -p local0.info -t dhcpcd.exe[$$] "${INTERFACE} has been configured with old IP=${IPADDR}" | |
bf7c473f | 73 | touch /var/ipfire/red/active |
bf7c473f MT |
74 | ;; |
75 | new) | |
76 | logger -p local0.info -t dhcpcd.exe[$$] "${INTERFACE} has been configured with new IP=${IPADDR}" | |
77 | if [ -e "/var/ipfire/red/active" ]; then | |
78 | /usr/local/bin/setfilters | |
79 | /usr/local/bin/setportfw | |
80 | /usr/local/bin/setxtaccess | |
81 | /usr/local/bin/setddns.pl -f | |
cce90b0b | 82 | /usr/local/bin/snortctrl restart |
bf7c473f MT |
83 | sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S & |
84 | /bin/rm -f /var/lock/red.lock | |
85 | logger -p local0.info -t red[$$] "unlocking from $$" | |
86 | exit 0 | |
87 | else | |
bf7c473f | 88 | touch /var/ipfire/red/active |
bf7c473f MT |
89 | fi |
90 | ;; | |
91 | down) | |
92 | logger -p local0.info -t dhcpcd.exe[$$] "${INTERFACE} has been brought down" | |
93 | rm -f /var/ipfire/red/active | |
94 | ;; | |
95 | esac | |
96 | fi | |
97 | ||
98 | if [ -e "/var/ipfire/red/active" ]; then | |
99 | [ "$IFACE" != "" ] && ifconfig $IFACE -multicast | |
100 | /etc/rc.d/init.d/firewall reload | |
101 | /usr/local/bin/setfilters | |
4cb74dce | 102 | /usr/local/bin/outgoingfwctrl |
cce90b0b | 103 | /usr/local/bin/snortctrl restart |
bf7c473f MT |
104 | /usr/local/bin/qosctrl start |
105 | /usr/local/bin/setportfw | |
106 | /usr/local/bin/setxtaccess | |
107 | /usr/local/bin/setddns.pl -f | |
108 | /etc/rc.d/helper/writeipac.pl | |
109 | /usr/sbin/fetchipac -S | |
110 | sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S & | |
111 | else | |
112 | /usr/local/bin/ipsecctrl D | |
113 | /etc/rc.d/init.d/firewall reload | |
114 | fi | |
115 | /bin/rm -f /var/lock/red.lock | |
116 | /usr/bin/logger -p local0.info -t red[$$] "unlocking from $$" | |
117 | ||
118 | # End $network_devices/red/update |