Hinzugefuegt:
[people/pmueller/ipfire-2.x.git] / src / rc.d / rc.updatered
CommitLineData
cd1a2927
MT
1#!/bin/sh
2#
3# $Id: rc.updatered,v 1.11.2.15 2005/12/01 16:20:37 franck78 Exp $
4#
5
6if [ ! -e /var/lock/rc.updatered.lock ]; then
7 /bin/touch /var/lock/rc.updatered.lock
8 /usr/bin/logger -s -p local0.info -t rc.updatered "$0 locking for $$"
9else
10 count=0
11 while [ ! $count = 5 ]; do
12 sleep 3
13 if [ ! -e /var/lock/rc.updatered.lock ]; then
14 break
15 else
16 /usr/bin/logger -s -p local0.info -t rc.updatered "$0 $$ waiting unlock"
17 fi
18 ((++count))
19 done
20fi
21
22eval $(/usr/local/bin/readhash CONFIG_ROOT/vpn/settings)
23eval $(/usr/local/bin/readhash CONFIG_ROOT/dhcp/settings)
24eval $(/usr/local/bin/readhash CONFIG_ROOT/ethernet/settings)
25eval $(/usr/local/bin/readhash CONFIG_ROOT/ppp/settings)
26
27IFACE=`/bin/cat CONFIG_ROOT/red/iface 2>/dev/null | /usr/bin/tr -d '\012'`
28REMOTE=`/bin/cat CONFIG_ROOT/red/remote-ipaddress 2>/dev/null | /usr/bin/tr -d '\012'`
29
30###
31### Retrieve DHCP Settings
32###
33if [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "6" -o "$CONFIG_TYPE" = "7" ]; then
34 if [ "$RED_TYPE" = "DHCP" ]; then
35 unset DNS1 DNS2
36 eval $(/usr/local/bin/readhash CONFIG_ROOT/ethernet/settings)
37 if [ "$DNS1" = "" ]; then
38 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > CONFIG_ROOT/red/dns1
39 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > CONFIG_ROOT/red/dns2
40 else
41 echo "$DNS1" > CONFIG_ROOT/red/dns1
42 echo "$DNS2" > CONFIG_ROOT/red/dns2
43 fi
44 . CONFIG_ROOT/dhcpc/dhcpcd-${RED_DEV}.info
45 echo "$IPADDR" > CONFIG_ROOT/red/local-ipaddress
46 echo "$GATEWAY" > CONFIG_ROOT/red/remote-ipaddress
47 fi
48else
49 if [ "$PROTOCOL" = "RFC1483" -a "$METHOD" = "DHCP" ]; then
50 unset DNS1 DNS2
51 eval $(/usr/local/bin/readhash CONFIG_ROOT/ppp/settings)
52 if [ "$DNS" = "Automatic" ]; then
53 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > CONFIG_ROOT/red/dns1
54 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > CONFIG_ROOT/red/dns2
55 else
56 echo "$DNS1" > CONFIG_ROOT/red/dns1
57 echo "$DNS2" > CONFIG_ROOT/red/dns2
58 fi
59 . CONFIG_ROOT/dhcpc/dhcpcd-${IFACE}.info
60 echo $IPADDR > CONFIG_ROOT/red/local-ipaddress
61 echo $GATEWAY > CONFIG_ROOT/red/remote-ipaddress
62 fi
63fi
64
65###
66### Retrieve DNS settings
67###
68DNS1=`/bin/cat CONFIG_ROOT/red/dns1 2>/dev/null | /usr/bin/tr -d '\012'`
69DNS2=`/bin/cat CONFIG_ROOT/red/dns2 2>/dev/null | /usr/bin/tr -d '\012'`
70echo > CONFIG_ROOT/red/resolv.conf #clear it
71[ "$DNS1" != "" ] && echo "nameserver $DNS1" > CONFIG_ROOT/red/resolv.conf
72[ "$DNS2" != "" ] && echo "nameserver $DNS2" >> CONFIG_ROOT/red/resolv.conf
73
74
75###
76### Restart DNSMASQ
77###
78/bin/killall -KILL dnsmasq 2> /dev/null
79sleep 1
80
81DOMopt=""
82[ "$DOMAIN_NAME_GREEN" ] && DOMopt="-s $DOMAIN_NAME_GREEN"
83if [ -e "CONFIG_ROOT/red/dial-on-demand" -a "$DIALONDEMANDDNS" == "on" -a ! -e "CONFIG_ROOT/red/active" ]; then
84 /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $DOMopt -r CONFIG_ROOT/ppp/fake-resolv.conf
85else
86 /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $DOMopt -r CONFIG_ROOT/red/resolv.conf
87fi
88unset DOMopt
89
90
91# Reset default route to ippp0 for dial on demand
92if [ -e "CONFIG_ROOT/red/dial-on-demand" -a "$TYPE" == "isdn" -a ! -e "CONFIG_ROOT/red/active" ]; then
93 /sbin/route del default 2> /dev/null
94 if [ ! -z "$REMOTE" ]; then
95 /sbin/route add default gw $REMOTE 2> /dev/null
96 else
97 /sbin/route add default dev ippp0 2> /dev/null
98 fi
99fi
100
101if ( echo $0 | /bin/grep -q 'dhcpcd.exe' ); then
102 eval $(/usr/local/bin/readhash "$1")
103 case "$2" in
104 up) /usr/bin/logger -s -p local0.info -t dhcpcd.exe "${INTERFACE} has been configured with old IP=${IPADDR}"
105 if [ "$RED_TYPE" != 'PPTP' ]; then
106 /bin/touch CONFIG_ROOT/red/active
107 fi
108 ;;
109 new) /usr/bin/logger -s -p local0.info -t dhcpcd.exe "${INTERFACE} has been configured with new IP=${IPADDR}"
110 if [ -e "CONFIG_ROOT/red/active" ]; then
111 /usr/local/bin/setfilters
112 /usr/local/bin/setportfw
113 /usr/local/bin/setxtaccess
114 /usr/local/bin/setddns.pl -f
115 /usr/local/bin/restartsnort red
116 sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S &
117 /bin/rm -f /var/lock/rc.updatered.lock
118 /usr/bin/logger -s -p local0.info -t rc.updatered "unlocking from $$"
119 exit 0
120 else
121 if [ "$RED_TYPE" != 'PPTP' ]; then
122 /bin/touch CONFIG_ROOT/red/active
123 fi
124 fi
125 ;;
126 down) /usr/bin/logger -s -p local0.info -t dhcpcd.exe "${INTERFACE} has been brought down"
127 rm -f CONFIG_ROOT/red/active
128 ;;
129 esac
130fi
131
132if [ -e "CONFIG_ROOT/red/active" ]; then
133 [ "$IFACE" != "" ] && /sbin/ifconfig $IFACE -multicast
134 /etc/rc.d/rc.firewall reload
135 /usr/local/bin/setfilters
cd1a2927 136 /usr/local/bin/restartsnort red
a5ee5623 137 /usr/local/bin/qosctrl restart
cd1a2927
MT
138 /usr/local/bin/setportfw
139 /usr/local/bin/setxtaccess
140 /usr/local/bin/setddns.pl -f
141 /etc/rc.d/helper/writeipac.pl
142 /usr/sbin/fetchipac -S
143 sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S &
144else
145 /usr/local/bin/ipsecctrl D
146 /etc/rc.d/rc.firewall reload
147fi
148/bin/rm -f /var/lock/rc.updatered.lock
149/usr/bin/logger -s -p local0.info -t rc.updatered "unlocking from $$"