| 1 |
#!/bin/bash |
| 2 |
# Copyright (c) 2004-2005 Gentoo Foundation |
| 3 |
# Distributed under the terms of the GNU General Public License v2 |
| 4 |
|
| 5 |
# Contributed by Roy Marples (uberlord@gentoo.org) |
| 6 |
|
| 7 |
# Instead of writing new functions for dhclient, we simply map their variables |
| 8 |
# over to udhcpc style ones and call those scripts! |
| 9 |
|
| 10 |
case "${reason}" in |
| 11 |
BOUND|REBOOT|REBIND) action="bound" ;; |
| 12 |
RENEW) action="renew" ;; |
| 13 |
RELEASE|PREINIT|FAIL|EXPIRE|TIMEOUT) action="deconfig" ;; |
| 14 |
MEDIUM) exit 0 ;; |
| 15 |
esac |
| 16 |
|
| 17 |
if [[ -z ${action} ]]; then |
| 18 |
echo "dhclient sent an unknown action ${reason}!" >&2 |
| 19 |
exit 1 |
| 20 |
fi |
| 21 |
|
| 22 |
export ip="${new_ip_address}" |
| 23 |
export subnet="${new_subnet_mask}" |
| 24 |
export broadcast="${new_broadcast_address}" |
| 25 |
export routers="${new_routers}" |
| 26 |
|
| 27 |
export hostname="${new_host_name}" |
| 28 |
|
| 29 |
export dns_domain_${interface}="${new_domain_name}" |
| 30 |
export dns_servers_${interface}="${new_domain_name_servers}" |
| 31 |
|
| 32 |
export ntp_servers_${interface}="${new_domain_name_servers}" |
| 33 |
|
| 34 |
export nis_domain_${interface}="${new_nis_domain}" |
| 35 |
export nis_servers_${interface}="${new_nis_servers}" |
| 36 |
|
| 37 |
/lib/rcscripts/net.modules.d/helpers.d/dhcp "${action}" |
| 38 |
result="$?" |
| 39 |
|
| 40 |
[[ -e /etc/dhcp/dhclient-exit-hooks ]] \ |
| 41 |
&& ( . /etc/dhcp/dhclient-exit-hooks ) |
| 42 |
|
| 43 |
exit "${result}" |
| 44 |
|
| 45 |
# vim:ts=4 |