3
# $Id: rc.updatered,v 1.11.2.15 2005/12/01 16:20:37 franck78 Exp $
6
if [ ! -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 $$"
11
while [ ! $count = 5 ]; do
13
if [ ! -e /var/lock/rc.updatered.lock ]; then
16
/usr/bin/logger -s -p local0.info -t rc.updatered "$0 $$ waiting unlock"
22
eval $(/usr/local/bin/readhash CONFIG_ROOT/vpn/settings)
23
eval $(/usr/local/bin/readhash CONFIG_ROOT/dhcp/settings)
24
eval $(/usr/local/bin/readhash CONFIG_ROOT/ethernet/settings)
25
eval $(/usr/local/bin/readhash CONFIG_ROOT/ppp/settings)
27
IFACE=`/bin/cat CONFIG_ROOT/red/iface 2>/dev/null | /usr/bin/tr -d '\012'`
28
REMOTE=`/bin/cat CONFIG_ROOT/red/remote-ipaddress 2>/dev/null | /usr/bin/tr -d '\012'`
31
### Retrieve DHCP Settings
33
if [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "6" -o "$CONFIG_TYPE" = "7" ]; then
34
if [ "$RED_TYPE" = "DHCP" ]; then
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
41
echo "$DNS1" > CONFIG_ROOT/red/dns1
42
echo "$DNS2" > CONFIG_ROOT/red/dns2
44
. CONFIG_ROOT/dhcpc/dhcpcd-${RED_DEV}.info
45
echo "$IPADDR" > CONFIG_ROOT/red/local-ipaddress
46
echo "$GATEWAY" > CONFIG_ROOT/red/remote-ipaddress
49
if [ "$PROTOCOL" = "RFC1483" -a "$METHOD" = "DHCP" ]; then
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
56
echo "$DNS1" > CONFIG_ROOT/red/dns1
57
echo "$DNS2" > CONFIG_ROOT/red/dns2
59
. CONFIG_ROOT/dhcpc/dhcpcd-${IFACE}.info
60
echo $IPADDR > CONFIG_ROOT/red/local-ipaddress
61
echo $GATEWAY > CONFIG_ROOT/red/remote-ipaddress
66
### Retrieve DNS settings
68
DNS1=`/bin/cat CONFIG_ROOT/red/dns1 2>/dev/null | /usr/bin/tr -d '\012'`
69
DNS2=`/bin/cat CONFIG_ROOT/red/dns2 2>/dev/null | /usr/bin/tr -d '\012'`
70
echo > 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
78
/bin/killall -KILL dnsmasq 2> /dev/null
82
[ "$DOMAIN_NAME_GREEN" ] && DOMopt="-s $DOMAIN_NAME_GREEN"
83
if [ -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
86
/usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $DOMopt -r CONFIG_ROOT/red/resolv.conf
91
# Reset default route to ippp0 for dial on demand
92
if [ -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
97
/sbin/route add default dev ippp0 2> /dev/null
101
if ( echo $0 | /bin/grep -q 'dhcpcd.exe' ); then
102
eval $(/usr/local/bin/readhash "$1")
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
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 $$"
121
if [ "$RED_TYPE" != 'PPTP' ]; then
122
/bin/touch CONFIG_ROOT/red/active
126
down) /usr/bin/logger -s -p local0.info -t dhcpcd.exe "${INTERFACE} has been brought down"
127
rm -f CONFIG_ROOT/red/active
132
if [ -e "CONFIG_ROOT/red/active" ]; then
133
[ "$IFACE" != "" ] && /sbin/ifconfig $IFACE -multicast
134
/etc/rc.d/rc.firewall reload
135
/usr/local/bin/setfilters
136
/usr/local/bin/updatelists.pl &
137
/usr/local/bin/restartsnort red
139
eval $(/usr/local/bin/readhash CONFIG_ROOT/shaping/settings)
140
if [ "$ENABLE" == "on" ]; then
141
/usr/local/bin/restartshaping
143
/usr/local/bin/setportfw
144
/usr/local/bin/setxtaccess
145
/usr/local/bin/setddns.pl -f
146
/etc/rc.d/helper/writeipac.pl
147
/usr/sbin/fetchipac -S
148
sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S &
150
/usr/local/bin/ipsecctrl D
151
/etc/rc.d/rc.firewall reload
153
/bin/rm -f /var/lock/rc.updatered.lock
154
/usr/bin/logger -s -p local0.info -t rc.updatered "unlocking from $$"