]>
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 | # |
bedfda83 | 8 | # Version : 02.10 |
1393a0c8 MT |
9 | # |
10 | # Notes : | |
11 | # | |
12 | ######################################################################## | |
13 | ||
26617b09 AF |
14 | . /etc/sysconfig/rc |
15 | . $rc_functions | |
0e42072a | 16 | |
5ba06eb8 AF |
17 | |
18 | eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) | |
26617b09 AF |
19 | eval $(/usr/local/bin/readhash /var/ipfire/dns/settings) |
20 | ||
21d1c72e | 21 | dhcpcd_up() |
26617b09 AF |
22 | { |
23 | set | grep "^new_" | sed "s|^new_||g" | \ | |
24 | sort > /var/ipfire/dhcpc/dhcpcd-$interface.info | |
25 | ||
0c719f93 AF |
26 | #Check if this was the Red device... |
27 | if [ ! "$interface" == "$RED_DEV" ]; then | |
28 | exit 0; | |
29 | fi | |
30 | ||
5ba06eb8 AF |
31 | # Only if RED_TYPE=DHCP update /var/ipfire/red |
32 | if [ "$RED_TYPE" == "DHCP" ]; then | |
26617b09 AF |
33 | |
34 | #Check if we have to restart the services at update | |
44b2f168 | 35 | [ ! -e "/var/ipfire/red/active" ] && update=1; |
26617b09 AF |
36 | if [ "$old_domain_name_service" != "$new_domain_name_service" ]; then |
37 | update=1; | |
38 | fi | |
39 | if [ "$old_ip_address" != "$new_ip_address" ]; then | |
40 | update=1; | |
41 | fi | |
42 | if [ "$old_routers" != "$new_routers" ]; then | |
43 | update=1; | |
44 | fi | |
45 | ||
46 | #Get DNS from dhcp | |
47 | if [ -n "$DNS0" ] && [ -n "$DNS1" ]; then | |
48 | logger -p local0.info -t dhcpcd.exe[$$] "Overwritting DNS-Server addresses with ${DNS0},${DNS1}" | |
49 | echo -n ${DNS0} > /var/ipfire/red/dns1 | |
50 | echo -n ${DNS1} > /var/ipfire/red/dns2 | |
51 | else | |
52 | echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1 | |
53 | echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2 | |
54 | fi | |
55 | ||
56 | #Get IP Address | |
14e30bab | 57 | echo -n "$new_ip_address" > /var/ipfire/red/local-ipaddress |
26617b09 AF |
58 | |
59 | #Get default gateway | |
3d9d5884 AF |
60 | grep -v -E "\<gateway\>" /etc/hosts > /tmp/hosts |
61 | echo "$new_routers gateway" >> /tmp/hosts | |
26617b09 AF |
62 | mv /tmp/hosts /etc/hosts |
63 | ||
64 | fi | |
65 | if [ $update ]; then | |
1393a0c8 | 66 | [ -e "/var/ipfire/red/active" ] || touch /var/ipfire/red/active |
14e30bab | 67 | echo -n "$new_routers" > /var/ipfire/red/remote-ipaddress |
26617b09 | 68 | logger -p local0.info -t dhcpcd.exe[$$] "$interface has been (re)configured with IP=$new_ip_address" |
0e42072a | 69 | run_subdir ${rc_base}/init.d/networking/red.up/ |
26617b09 AF |
70 | touch /var/ipfire/red/active |
71 | fi | |
72 | } | |
73 | ||
21d1c72e | 74 | dhcpcd_down() |
26617b09 | 75 | { |
21d1c72e AF |
76 | set | grep "^new_" | sed "s|^new_||g" | \ |
77 | sort > /var/ipfire/dhcpc/dhcpcd-$interface.info | |
5ba06eb8 AF |
78 | |
79 | # Only if RED_TYPE=DHCP update /var/ipfire/red | |
80 | if [ "$RED_TYPE" == "DHCP" ]; then | |
21d1c72e | 81 | rm -f /var/ipfire/red/active |
455291f9 | 82 | if [ ! $reason == "PREINIT" ]; then |
bedfda83 | 83 | logger -p local0.info -t dhcpcd.exe[$$] "${interface} has been brought down ($reason)" |
455291f9 AF |
84 | run_subdir ${rc_base}/init.d/networking/red.down/ |
85 | fi | |
21d1c72e | 86 | fi |
26617b09 | 87 | } |
1393a0c8 | 88 | |
26617b09 | 89 | case "$reason" in |
21d1c72e | 90 | BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) dhcpcd_up;; |
bedfda83 | 91 | PREINIT|EXPIRE|FAIL|IPV4LL|NAK|RELEASE|STOP) dhcpcd_down;; |
26617b09 | 92 | esac |