aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-hooks
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-01-24 16:27:51 -0800
committerDmitry Shmidt <dimitrysh@google.com>2011-01-24 16:27:51 -0800
commite86eee143ed21592f88a46623a81f71002430459 (patch)
treee0be4ce113729bce176fd5054aeaf51a88b2e169 /dhcpcd-hooks
parent6bcc301d166624837871fd601b4d3b5d43551e6b (diff)
downloadexternal_dhcpcd-e86eee143ed21592f88a46623a81f71002430459.zip
external_dhcpcd-e86eee143ed21592f88a46623a81f71002430459.tar.gz
external_dhcpcd-e86eee143ed21592f88a46623a81f71002430459.tar.bz2
dhcpcd: Update to Version 5.2.10
Change-Id: I949331c7aad91b125decd51da4041983d3a352bc Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'dhcpcd-hooks')
-rw-r--r--dhcpcd-hooks/02-dump5
-rw-r--r--dhcpcd-hooks/20-resolv.conf101
-rw-r--r--dhcpcd-hooks/29-lookup-hostname18
-rw-r--r--dhcpcd-hooks/30-hostname26
-rw-r--r--dhcpcd-hooks/50-dhcpcd-compat44
-rw-r--r--dhcpcd-hooks/50-ntp.conf87
-rw-r--r--dhcpcd-hooks/50-yp.conf44
-rw-r--r--dhcpcd-hooks/50-ypbind74
-rw-r--r--dhcpcd-hooks/Makefile26
9 files changed, 273 insertions, 152 deletions
diff --git a/dhcpcd-hooks/02-dump b/dhcpcd-hooks/02-dump
new file mode 100644
index 0000000..cbb46ea
--- /dev/null
+++ b/dhcpcd-hooks/02-dump
@@ -0,0 +1,5 @@
+# Just echo our DHCP options we have
+
+if [ "$reason" = "DUMP" ]; then
+ set | sed -ne 's/^new_//p' | sort
+fi
diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf
index e757ddf..628636d 100644
--- a/dhcpcd-hooks/20-resolv.conf
+++ b/dhcpcd-hooks/20-resolv.conf
@@ -6,102 +6,121 @@
# Also, resolvconf can configure local nameservers such as bind
# or dnsmasq. This is important as the libc resolver isn't that powerful.
-resolv_conf_dir="${state_dir}/resolv.conf"
+resolv_conf_dir="$state_dir/resolv.conf"
build_resolv_conf()
{
- local cf="/etc/resolv.conf.${interface}"
+ local cf="$state_dir/resolv.conf.$interface"
local interfaces= header= search= srvs= servers= x=
# Build a list of interfaces
- interfaces=$(list_interfaces "${resolv_conf_dir}")
+ interfaces=$(list_interfaces "$resolv_conf_dir")
# Build the resolv.conf
- if [ -n "${interfaces}" ]; then
+ if [ -n "$interfaces" ]; then
# Build the header
for x in ${interfaces}; do
- header="${header}${header:+, }${x}"
+ header="$header${header:+, }$x"
done
# Build the search list
- search=$(cd "${resolv_conf_dir}"; \
+ domain=$(cd "$resolv_conf_dir"; \
+ key_get_value "domain " ${interfaces})
+ search=$(cd "$resolv_conf_dir"; \
key_get_value "search " ${interfaces})
- [ -n "${search}" ] && search="search $(uniqify ${search})\n"
+ set -- ${domain}
+ unset domain
+ if [ -n "$2" ]; then
+ search="$search $@"
+ elif [ -n "$1" ]; then
+ domain="domain $1\n"
+ fi
+ [ -n "$search" ] && search="search $(uniqify $search)\n"
# Build the nameserver list
- srvs=$(cd "${resolv_conf_dir}"; \
+ srvs=$(cd "$resolv_conf_dir"; \
key_get_value "nameserver " ${interfaces})
for x in $(uniqify ${srvs}); do
- servers="${servers}nameserver ${x}\n"
+ servers="${servers}nameserver $x\n"
done
fi
- header="${signature_base}${header:+ ${from} }${header}"
+ header="$signature_base${header:+ $from }$header"
# Assemble resolv.conf using our head and tail files
- [ -f "${cf}" ] && rm -f "${cf}"
- echo "${header}" > "${cf}"
+ [ -f "$cf" ] && rm -f "$cf"
+ [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
+ echo "$header" > "$cf"
if [ -f /etc/resolv.conf.head ]; then
- cat /etc/resolv.conf.head >> "${cf}"
+ cat /etc/resolv.conf.head >> "$cf"
else
- echo "# /etc/resolv.conf.head can replace this line" >> "${cf}"
+ echo "# /etc/resolv.conf.head can replace this line" >> "$cf"
fi
- printf "${search}${servers}" >> "${cf}"
+ printf "$domain$search$servers" >> "$cf"
if [ -f /etc/resolv.conf.tail ]; then
- cat /etc/resolv.conf.tail >> "${cf}"
+ cat /etc/resolv.conf.tail >> "$cf"
else
- echo "# /etc/resolv.conf.tail can replace this line" >> "${cf}"
+ echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
fi
- mv -f "${cf}" /etc/resolv.conf
+ cat "$cf" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ rm -f "$cf"
}
add_resolv_conf()
{
- local x= conf="${signature}\n"
+ local x= conf="$signature\n"
# If we don't have any configuration, remove it
- if [ -z "${new_domain_name_servers}" -a \
- -z "${new_domain_name}" -a \
- -z "${new_domain_search}" ]; then
+ if [ -z "$new_domain_name_servers" -a \
+ -z "$new_domain_name" -a \
+ -z "$new_domain_search" ]; then
remove_resolv_conf
return $?
fi
- if [ -n "${new_domain_search}" ]; then
- conf="${conf}search ${new_domain_search}\n"
- elif [ -n "${new_domain_name}" ]; then
- conf="${conf}search ${new_domain_name}\n"
+ if [ -n "$new_domain_name" ]; then
+ set -- $new_domain_name
+ new_domain_name="$1"
+ conf="${conf}domain $new_domain_name\n"
+ # Support RFC violating search in domain
+ if [ -z "$new_domain_search" -a -n "$2" ]; then
+ new_domain_search="$@"
+ fi
+ fi
+ if [ -n "$new_domain_search" ]; then
+ conf="${conf}search $new_domain_search\n"
fi
for x in ${new_domain_name_servers}; do
- conf="${conf}nameserver ${x}\n"
+ conf="${conf}nameserver $x\n"
done
if type resolvconf >/dev/null 2>&1; then
- printf "${conf}" | resolvconf -a "${interface}"
+ [ -n "$metric" ] && export IF_METRIC="$metric"
+ printf "$conf" | resolvconf -a "$interface"
return $?
fi
- if [ -e "${resolv_conf_dir}/${interface}" ]; then
- rm -f "${resolv_conf_dir}/${interface}"
- fi
- if [ ! -d "${resolv_conf_dir}" ]; then
- mkdir -p "${resolv_conf_dir}"
+ if [ -e "$resolv_conf_dir/$interface" ]; then
+ rm -f "$resolv_conf_dir/$interface"
fi
- printf "${conf}" > "${resolv_conf_dir}/${interface}"
+ [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
+ printf "$conf" > "$resolv_conf_dir/$interface"
build_resolv_conf
}
remove_resolv_conf()
{
if type resolvconf >/dev/null 2>&1; then
- resolvconf -d "${interface}" -f
+ resolvconf -d "$interface" -f
else
- if [ -e "${resolv_conf_dir}/${interface}" ]; then
- rm -f "${resolv_conf_dir}/${interface}"
+ if [ -e "$resolv_conf_dir/$interface" ]; then
+ rm -f "$resolv_conf_dir/$interface"
fi
build_resolv_conf
fi
}
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) add_resolv_conf;;
-PREINIT|EXPIRE|FAIL|IPV4LL|RELEASE|STOP) remove_resolv_conf;;
-esac
+if $if_up; then
+ add_resolv_conf
+elif $if_down; then
+ remove_resolv_conf
+fi
diff --git a/dhcpcd-hooks/29-lookup-hostname b/dhcpcd-hooks/29-lookup-hostname
index 3dfade3..8661fcc 100644
--- a/dhcpcd-hooks/29-lookup-hostname
+++ b/dhcpcd-hooks/29-lookup-hostname
@@ -2,19 +2,19 @@
lookup_hostname()
{
- [ -z "${new_ip_address}" ] && return 1
+ [ -z "$new_ip_address" ] && return 1
local h=
# Silly ISC programs love to send error text to stdout
if type dig >/dev/null 2>&1; then
- h=`dig +short -x ${new_ip_address}`
+ h=$(dig +short -x $new_ip_address)
if [ $? = 0 ]; then
- echo "${h}" | sed 's/\.$//'
+ echo "$h" | sed 's/\.$//'
return 0
fi
elif type host >/dev/null 2>&1; then
- h=`host ${new_ip_address}`
+ h=$(host $new_ip_address)
if [ $? = 0 ]; then
- echo "${h}" \
+ echo "$h" \
| sed 's/.* domain name pointer \(.*\)./\1/'
return 0
fi
@@ -24,11 +24,11 @@ lookup_hostname()
set_hostname()
{
- if [ -z "${new_host_name}" -a -z "${new_fqdn_name}" ]; then
+ if [ -z "$new_host_name" -a -z "$new_fqdn_name" ]; then
export new_host_name="$(lookup_hostname)"
fi
}
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_hostname;;
-esac
+if $if_up; then
+ set_hostname
+fi
diff --git a/dhcpcd-hooks/30-hostname b/dhcpcd-hooks/30-hostname
index b2e5fc8..87446fb 100644
--- a/dhcpcd-hooks/30-hostname
+++ b/dhcpcd-hooks/30-hostname
@@ -2,10 +2,16 @@
need_hostname()
{
- case "$(hostname)" in
+ local hostname=""
+
+ case "$force_hostname" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) ;;
+ *) hostname="$(hostname)";;
+ esac
+ case "$hostname" in
""|"(none)"|localhost|localhost.localdomain)
- [ -n "${new_host_name}" -o -n "${new_fqdn_name}" ];;
- "${old_host_name}"|"${old_fqdn_name}")
+ [ -n "$new_host_name" -o -n "$new_fqdn_name" ];;
+ "$old_host_name"|"$old_fqdn_name")
true;;
*)
false;;
@@ -15,14 +21,14 @@ need_hostname()
set_hostname()
{
if need_hostname; then
- if [ -n "${new_host_name}" ]; then
- hostname "${new_host_name}"
- else
- hostname "${new_fqdn_name}"
+ if [ -n "$new_host_name" ]; then
+ hostname "$new_host_name"
+ elif [ -n "$new_fqdn_name" ]; then
+ hostname "$new_fqdn_name"
fi
fi
}
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_hostname;;
-esac
+if $if_up; then
+ set_hostname
+fi
diff --git a/dhcpcd-hooks/50-dhcpcd-compat b/dhcpcd-hooks/50-dhcpcd-compat
index bb31fd3..651bc08 100644
--- a/dhcpcd-hooks/50-dhcpcd-compat
+++ b/dhcpcd-hooks/50-dhcpcd-compat
@@ -1,41 +1,41 @@
# Compat enter hook shim for older dhcpcd versions
-IPADDR=${new_ip_address}
-INTERFACE=${interface}
-NETMASK=${new_subnet_mask}
-BROADCAST=${new_broadcast_address}
-NETWORK=${new_network_number}
-DHCPSID=${new_dhcp_server_identifier}
-GATEWAYS=${new_routers}
-DNSSERVERS=${new_domain_name_servers}
-DNSDOMAIN=${new_domain_name}
-DNSSEARCH=${new_domain_search}
-NISDOMAIN=${new_nis_domain}
-NISSERVERS=${new_nis_servers}
-NTPSERVERS=${new_ntp_servers}
+IPADDR=$new_ip_address
+INTERFACE=$interface
+NETMASK=$new_subnet_mask
+BROADCAST=$new_broadcast_address
+NETWORK=$new_network_number
+DHCPSID=$new_dhcp_server_identifier
+GATEWAYS=$new_routers
+DNSSERVERS=$new_domain_name_servers
+DNSDOMAIN=$new_domain_name
+DNSSEARCH=$new_domain_search
+NISDOMAIN=$new_nis_domain
+NISSERVERS=$new_nis_servers
+NTPSERVERS=$new_ntp_servers
GATEWAY=
-for x in ${new_routers}; do
- GATEWAY="${GATEWAY}${GATEWAY:+,}${x}"
+for x in $new_routers; do
+ GATEWAY="$GATEWAY${GATEWAY:+,}$x"
done
DNS=
-for x in ${new_domain_name_servers}; do
- DNS="${DNS}${DNS:+,}${x}"
+for x in $new_domain_name_servers; do
+ DNS="$DNS${DNS:+,}$x"
done
x="down"
-case "${reason}" in
+case "$reason" in
RENEW) x="up";;
BOUND|INFORM|REBIND|REBOOT|TEST|TIMEOUT|IPV4LL) x="new";;
esac
-if [ "${reason}" != "down" ]; then
- rm -f /var/lib/dhcpcd-"${INTERFACE}".info
+if [ "$reason" != "down" ]; then
+ rm -f /var/lib/dhcpcd-"$INTERFACE".info
for x in IPADDR INTERFACE NETMASK BROADCAST NETWORK DHCPSID GATEWAYS \
DNSSERVERS DNSDOMAIN DNSSEARCH NISDOMAIN NISSERVERS \
NTPSERVERS GATEWAY DNS; do
- eval echo "${x}=\'\$${x}\'" >> /var/lib/dhcpcd-"${INTERFACE}".info
+ eval echo "$x=\'\$$x\'" >> /var/lib/dhcpcd-"$INTERFACE".info
done
fi
-set -- /var/lib/dhcpcd-"${INTERFACE}".info "${x}"
+set -- /var/lib/dhcpcd-"$INTERFACE".info "$x"
diff --git a/dhcpcd-hooks/50-ntp.conf b/dhcpcd-hooks/50-ntp.conf
index 8c92f27..765baa7 100644
--- a/dhcpcd-hooks/50-ntp.conf
+++ b/dhcpcd-hooks/50-ntp.conf
@@ -8,68 +8,76 @@
# NTP_CONF=/usr/pkg/etc/ntpd.conf
# to use openntpd from pkgsrc instead of the system provided ntp.
-# Detect OpenRC or BSD rc
-# Distributions may want to just have their command here instead of this
-if type rc-service >/dev/null 2>&1 && rc-service --exists ntpd; then
- ntpd_restart_cmd="rc-service ntpd -- --ifstarted --quiet restart"
-elif [ -x /etc/rc.d/ntpd ]; then
- ntpd_restart_cmd="/etc/rc.d/ntpd status && /etc/rc.d/ntpd restart"
-elif [ -x /usr/local/etc/rc.d/ntpd ]; then
- ntpd_restart_cmd="/usr/local/etc/rc.d/ntpd status && /usr/local/etc/rc.d/ntpd restart"
+: ${ntpd_restart_cmd:=service_condcommand ntpd restart}
+if type invoke-rc.d >/dev/null 2>&1; then
+ # Debian has a seperate file for DHCP config to avoid stamping on
+ # the master.
+ [ -e /var/lib/ntp ] || mkdir /var/lib/ntp
+ : ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
fi
-ntp_conf_dir="${state_dir}/ntp.conf"
+ntp_conf_dir="$state_dir/ntp.conf"
ntp_conf=${NTP_CONF:-/etc/ntp.conf}
build_ntp_conf()
{
- local cf="${ntp_conf}.${interface}"
+ local cf="$state_dir/ntp.conf.$interface"
local interfaces= header= srvs= servers= x=
# Build a list of interfaces
- interfaces=$(list_interfaces "${ntp_conf_dir}")
+ interfaces=$(list_interfaces "$ntp_conf_dir")
- if [ -n "${interfaces}" ]; then
+ if [ -n "$interfaces" ]; then
# Build the header
for x in ${interfaces}; do
- header="${header}${header:+, }${x}"
+ header="$header${header:+, }$x"
done
# Build a server list
- srvs=$(cd "${ntp_conf_dir}";
- key_get_value "server " ${interfaces})
- if [ -n "${srvs}" ]; then
- for x in $(uniqify ${srvs}); do
- servers="${servers}server ${x}\n"
+ srvs=$(cd "$ntp_conf_dir";
+ key_get_value "server " $interfaces)
+ if [ -n "$srvs" ]; then
+ for x in $(uniqify $srvs); do
+ servers="${servers}server $x\n"
done
fi
fi
# Merge our config into ntp.conf
- [ -e "${cf}" ] && rm -f "${cf}"
- remove_markers "${signature_base}" "${signature_base_end}" \
- /etc/ntp.conf > "${cf}"
- if [ -n "${servers}" ]; then
- echo "${signature_base}${header:+ ${from} }${header}" >> "${cf}"
- printf "${search}${servers}" >> "${cf}"
- echo "${signature_base_end}${header:+ ${from} }${header}" >> "${cf}"
+ [ -e "$cf" ] && rm -f "$cf"
+ [ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
+
+ if [ -n "$NTP_DHCP_CONF" ]; then
+ cp "$ntp_conf" "$cf"
+ ntp_conf="$NTP_DHCP_CONF"
+ elif [ -e "$ntp_conf" ]; then
+ remove_markers "$signature_base" "$signature_base_end" \
+ "$ntp_conf" > "$cf"
+ fi
+
+ if [ -n "$servers" ]; then
+ echo "$signature_base${header:+ $from }$header" >> "$cf"
+ printf "$search$servers" >> "$cf"
+ echo "$signature_base_end${header:+ $from }$header" >> "$cf"
+ else
+ [ -e "$ntp_conf" ] || return
fi
# If we changed anything, restart ntpd
- if change_file "${ntp_conf}" "${cf}"; then
- [ -n "${ntpd_restart_cmd}" ] && eval ${ntpd_restart_cmd}
+ if change_file "$ntp_conf" "$cf"; then
+ [ -n "$ntpd_restart_cmd" ] && eval $ntpd_restart_cmd
fi
}
add_ntp_conf()
{
- local cf="${ntp_conf_dir}/${interface}" x=
+ local cf="$ntp_conf_dir/$interface" x=
- [ -e "${cf}" ] && rm "${cf}"
- [ -d "${ntp_conf_dir}" ] || mkdir -p "${ntp_conf_dir}"
- if [ -n "${new_ntp_servers}" ]; then
- for x in ${new_ntp_servers}; do
- echo "server ${x}" >> "${cf}"
+ [ -e "$cf" ] && rm "$cf"
+ [ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
+ if [ -n "$new_ntp_servers" ]; then
+ for x in $new_ntp_servers; do
+ echo "server $x" >> "$cf"
done
fi
build_ntp_conf
@@ -77,13 +85,14 @@ add_ntp_conf()
remove_ntp_conf()
{
- if [ -e "${ntp_conf_dir}/${interface}" ]; then
- rm "${ntp_conf_dir}/${interface}"
+ if [ -e "$ntp_conf_dir/$interface" ]; then
+ rm "$ntp_conf_dir/$interface"
fi
build_ntp_conf
}
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) add_ntp_conf add;;
-PREINIT|EXPIRE|FAIL|IPV4LL|RELEASE|STOP) remove_ntp_conf del;;
-esac
+if $if_up; then
+ add_ntp_conf add
+elif $if_down; then
+ remove_ntp_conf del
+fi
diff --git a/dhcpcd-hooks/50-yp.conf b/dhcpcd-hooks/50-yp.conf
index a2296eb..a1f5798 100644
--- a/dhcpcd-hooks/50-yp.conf
+++ b/dhcpcd-hooks/50-yp.conf
@@ -8,42 +8,44 @@ ypbind_pid()
make_yp_conf()
{
- [ -z "${new_nis_domain}" -a -z "${new_nis_servers}" ] && return 0
- local cf=/etc/yp.conf."${interface}" prefix= x= pid=
- rm -f "${cf}"
- echo "${signature}" > "${cf}"
- if [ -n "${new_nis_domain}" ]; then
- domainname "${new_nis_domain}"
- if [ -n "${new_nis_servers}" ]; then
- prefix="domain ${new_nis_domain} server "
+ [ -z "$new_nis_domain" -a -z "$new_nis_servers" ] && return 0
+ local cf=/etc/yp.conf."$interface" prefix= x= pid=
+ rm -f "$cf"
+ echo "$signature" > "$cf"
+ if [ -n "$new_nis_domain" ]; then
+ domainname "$new_nis_domain"
+ if [ -n "$new_nis_servers" ]; then
+ prefix="domain $new_nis_domain server "
else
- echo "domain ${new_nis_domain} broadcast" >> "${cf}"
+ echo "domain $new_nis_domain broadcast" >> "$cf"
fi
else
prefix="ypserver "
fi
- for x in ${new_nis_servers}; do
- echo "${prefix}${x}" >> "${cf}"
+ for x in $new_nis_servers; do
+ echo "$prefix$x" >> "$cf"
done
save_conf /etc/yp.conf
- mv -f "${cf}" /etc/yp.conf
+ cat "$cf" > /etc/yp.conf
+ rm -f "$cf"
pid="$(ypbind_pid)"
- if [ -n "${pid}" ]; then
- kill -HUP "${pid}"
+ if [ -n "$pid" ]; then
+ kill -HUP "$pid"
fi
}
restore_yp_conf()
{
- [ -n "${old_nis_domain}" ] && domainname ""
+ [ -n "$old_nis_domain" ] && domainname ""
restore_conf /etc/yp.conf || return 0
local pid="$(ypbind_pid)"
- if [ -n "${pid}" ]; then
- kill -HUP "${pid}"
+ if [ -n "$pid" ]; then
+ kill -HUP "$pid"
fi
}
-case "${reason}" in
-BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) make_yp_conf;;
-EXPIRE|FAIL|IPV4LL|RELEASE|STOP) restore_yp_conf;;
-esac
+if $if_up; then
+ make_yp_conf
+elif $if_down; then
+ restore_yp_conf
+fi
diff --git a/dhcpcd-hooks/50-ypbind b/dhcpcd-hooks/50-ypbind
new file mode 100644
index 0000000..9a1fecc
--- /dev/null
+++ b/dhcpcd-hooks/50-ypbind
@@ -0,0 +1,74 @@
+# Sample dhcpcd hook for ypbind
+# This script is only suitable for the Linux version.
+
+: ${ypbind_restart_cmd:=service_command ypbind restart}
+: ${ypbind_stop_cmd:=service_condcommand ypbind stop}
+ypbind_dir="$state_dir/ypbind"
+
+best_domain()
+{
+ local i=
+
+ for i in $interfaces; do
+ if [ -e "$ypbind_dir/$i" ]; then
+ cat "$ypbind_dir/$i"
+ fi
+ done
+ return 1
+}
+
+make_yp_binding()
+{
+ [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
+ echo "$new_nis_domain" >"$ypbind_dir/$interface"
+ local nd="$(best_domain)"
+
+ local cf=/var/yp/binding/"$new_nis_domain".ypservers
+ if [ -n "$new_nis_servers" ]; then
+ local ncf="$cf.$interface" x=
+ rm -f "$ncf"
+ for x in $new_nis_servers; do
+ echo "$x" >>"$ncf"
+ done
+ change_file "$cf" "$ncf"
+ else
+ # Because this is not an if .. fi then we can use $? below
+ [ -e "$cf" ] && rm "$cf"
+ fi
+
+ if [ $? = 0 -o "$nd" != "$(domainname)" ]; then
+ domainname "$nd"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+restore_yp_binding()
+{
+ rm -f "$ypbind_dir/$interface"
+ local nd="$(best_domain)"
+ # We need to stop ypbind if there is no best domain
+ # otherwise it will just stall as we cannot set domainname
+ # to blank :/
+ if [ -z "$nd" ]; then
+ if [ -n "$ypbind_stop_cmd" ]; then
+ eval $ypbind_stop_cmd
+ fi
+ elif [ "$nd" != "$(domainname)" ]; then
+ domainname "$nd"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+if [ "$reason" = PREINIT ]; then
+ rm -f "$ypbind_dir/$interface"
+elif $if_up || $if_down; then
+ if [ -n "$new_nis_domain" ]; then
+ make_yp_binding
+ elif [ -n "$old_nis_domain" ]; then
+ restore_yp_binding
+ fi
+fi
diff --git a/dhcpcd-hooks/Makefile b/dhcpcd-hooks/Makefile
index cfb19f7..7563d2d 100644
--- a/dhcpcd-hooks/Makefile
+++ b/dhcpcd-hooks/Makefile
@@ -1,13 +1,19 @@
-LIBEXECDIR?= ${PREFIX}/libexec
-HOOKDIR= ${LIBEXECDIR}/dhcpcd-hooks
-SYSTEMSCRIPTS= 01-test 10-mtu 20-resolv.conf 30-hostname
-FILES= ${SYSTEMSCRIPTS} ${HOOKSCRIPTS}
-FILESDIR= ${HOOKDIR}
+TOP?= ../
+include ${TOP}/Makefile.inc
+include ${TOP}/config.mk
+
+SCRIPTSDIR= ${LIBEXECDIR}/dhcpcd-hooks
+SCRIPTS= 01-test 02-dump
+SCRIPTS+= 10-mtu 20-resolv.conf 29-lookup-hostname 30-hostname
+SCRIPTS+= ${HOOKSCRIPTS}
all:
-MK= ../mk
-include ${MK}/os.mk
-include ${MK}/sys.mk
-include ${MK}/files.mk
-install: _filesinstall
+install:
+ ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
+ ${INSTALL} -m ${NONBINMODE} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR}
+
+import:
+ ${INSTALL} -d /tmp/${DISTPREFIX}/dhcpcd-hooks
+ ${INSTALL} -m ${NONBINMODE} ${SCRIPTS} /tmp/${DISTPREFIX}/dhcpcd-hooks
+