]>
Commit | Line | Data |
---|---|---|
1393a0c8 MT |
1 | ######################################################################## |
2 | # Begin | |
3 | # | |
4 | # Description : DHCP Client Script | |
5 | # | |
26617b09 | 6 | # Authors : Arne Fitzenreiter - arne_f@ipfire.org |
1393a0c8 | 7 | # |
26617b09 | 8 | # Version : 02.00 |
1393a0c8 MT |
9 | # |
10 | # Notes : | |
11 | # | |
12 | ######################################################################## | |
13 | ||
26617b09 AF |
14 | . /etc/sysconfig/rc |
15 | . $rc_functions | |
0e42072a | 16 | |
26617b09 AF |
17 | eval $(/usr/local/bin/readhash /var/ipfire/dns/settings) |
18 | ||
19 | create_dhcpcd_info() | |
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 | |
1393a0c8 | 59 | [ -e "/var/ipfire/red/active" ] || touch /var/ipfire/red/active |
26617b09 AF |
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" | |
0e42072a | 62 | run_subdir ${rc_base}/init.d/networking/red.up/ |
26617b09 AF |
63 | touch /var/ipfire/red/active |
64 | fi | |
65 | } | |
66 | ||
67 | remove_dhcpcd_info() | |
68 | { | |
69 | rm -f /var/ipfire/dhcpc/dhcpcd-$interface.info | |
70 | logger -p local0.info -t dhcpcd.exe[$$] "${interface} has been brought down" | |
71 | rm -f /var/ipfire/red/active | |
72 | run_subdir ${rc_base}/init.d/networking/red.down/ | |
73 | } | |
1393a0c8 | 74 | |
26617b09 AF |
75 | case "$reason" in |
76 | BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) create_dhcpcd_info;; | |
77 | PREINIT|EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) remove_dhcpcd_info;; | |
78 | esac |