summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rcscripts/net.modules.d/helpers.d/dhclient-wrapper')
-rwxr-xr-xlib/rcscripts/net.modules.d/helpers.d/dhclient-wrapper45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/rcscripts/net.modules.d/helpers.d/dhclient-wrapper b/lib/rcscripts/net.modules.d/helpers.d/dhclient-wrapper
new file mode 100755
index 0000000..075229d
--- /dev/null
+++ b/lib/rcscripts/net.modules.d/helpers.d/dhclient-wrapper
@@ -0,0 +1,45 @@
+#!/bin/bash
+# Copyright (c) 2004-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# Contributed by Roy Marples (uberlord@gentoo.org)
+
+# Instead of writing new functions for dhclient, we simply map their variables
+# over to udhcpc style ones and call those scripts!
+
+case "${reason}" in
+ BOUND|REBOOT|REBIND) action="bound" ;;
+ RENEW) action="renew" ;;
+ RELEASE|PREINIT|FAIL|EXPIRE|TIMEOUT) action="deconfig" ;;
+ MEDIUM) exit 0 ;;
+esac
+
+if [[ -z ${action} ]]; then
+ echo "dhclient sent an unknown action ${reason}!" >&2
+ exit 1
+fi
+
+export ip="${new_ip_address}"
+export subnet="${new_subnet_mask}"
+export broadcast="${new_broadcast_address}"
+export routers="${new_routers}"
+
+export hostname="${new_host_name}"
+
+export dns_domain_${interface}="${new_domain_name}"
+export dns_servers_${interface}="${new_domain_name_servers}"
+
+export ntp_servers_${interface}="${new_domain_name_servers}"
+
+export nis_domain_${interface}="${new_nis_domain}"
+export nis_servers_${interface}="${new_nis_servers}"
+
+/lib/rcscripts/net.modules.d/helpers.d/dhcp "${action}"
+result="$?"
+
+[[ -e /etc/dhcp/dhclient-exit-hooks ]] \
+&& ( . /etc/dhcp/dhclient-exit-hooks )
+
+exit "${result}"
+
+# vim:ts=4