]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/init.d/networking/dhcpcd.exe
d0e6599c35d9727e393fc55cdd885fa4713edc4e
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / networking / dhcpcd.exe
1 ########################################################################
2 # Begin
3 #
4 # Description : DHCP Client Script
5 #
6 # Authors : Arne Fitzenreiter - arne_f@ipfire.org
7 #
8 # Version : 02.00
9 #
10 # Notes :
11 #
12 ########################################################################
13
14 . /etc/sysconfig/rc
15 . $rc_functions
16
17 eval $(/usr/local/bin/readhash /var/ipfire/dns/settings)
18
19 dhcpcd_up()
20 {
21 set | grep "^new_" | sed "s|^new_||g" | \
22 sort > /var/ipfire/dhcpc/dhcpcd-$interface.info
23
24 # If interface is not red0.8 (vdsl-iptv) update /var/ipfire/red
25 if [ "$interface" != "red0.8" ]; then
26
27 #Check if we have to restart the services at update
28 [ ! -e "/var/ipfire/red/active" ] update=1;
29 if [ "$old_domain_name_service" != "$new_domain_name_service" ]; then
30 update=1;
31 fi
32 if [ "$old_ip_address" != "$new_ip_address" ]; then
33 update=1;
34 fi
35 if [ "$old_routers" != "$new_routers" ]; then
36 update=1;
37 fi
38
39 #Get DNS from dhcp
40 if [ -n "$DNS0" ] && [ -n "$DNS1" ]; then
41 logger -p local0.info -t dhcpcd.exe[$$] "Overwritting DNS-Server addresses with ${DNS0},${DNS1}"
42 echo -n ${DNS0} > /var/ipfire/red/dns1
43 echo -n ${DNS1} > /var/ipfire/red/dns2
44 else
45 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1
46 echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2
47 fi
48
49 #Get IP Address
50 echo "$new_ip_address" > /var/ipfire/red/local-ipaddress
51
52 #Get default gateway
53 grep -v " gateway$" /etc/hosts > /tmp/hosts
54 echo "$new_routers gateway" >> /tmp/hosts
55 mv /tmp/hosts /etc/hosts
56
57 fi
58 if [ $update ]; then
59 [ -e "/var/ipfire/red/active" ] || touch /var/ipfire/red/active
60 echo "$new_routers" > /var/ipfire/red/remote-ipaddress
61 logger -p local0.info -t dhcpcd.exe[$$] "$interface has been (re)configured with IP=$new_ip_address"
62 run_subdir ${rc_base}/init.d/networking/red.up/
63 touch /var/ipfire/red/active
64 fi
65 }
66
67 dhcpcd_down()
68 {
69 set | grep "^new_" | sed "s|^new_||g" | \
70 sort > /var/ipfire/dhcpc/dhcpcd-$interface.info
71 if [ "$interface" != "red0.8" ]; then
72 logger -p local0.info -t dhcpcd.exe[$$] "${interface} has been brought down"
73 rm -f /var/ipfire/red/active
74 run_subdir ${rc_base}/init.d/networking/red.down/
75 fi
76 }
77
78 case "$reason" in
79 BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) dhcpcd_up;;
80 PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) dhcpcd_down;;
81 esac