configure now detects ntpd and ypbind for automatic hook install.
NetBSD-5.0
+To prepare dhcpcd for import into a platform source tree (like NetBSD)
+you can use the make import target to create /tmp/dhcpcd-$version and
+populate it with all the source files and hooks needed.
+
+
Hooks
-----
Not all the hooks in dhcpcd-hooks are installed by default.
By default we install 01-test, 10-mtu, 20-resolv.conf,
29-lookup-hostname and 30-hostname.
The default dhcpcd.conf disables the lookup-hostname hook by default.
+The configure program attempts to find hooks for systems you have installed.
To add more simply
./configure -with-hook=ntp.conf
: ${RUNDIR:=$STATEDIR/run}
: ${MANDIR:=${PREFIX:-/usr}/share/man}
+_which()
+{
+ x="$(which "$1" 2>/dev/null)"
+ if [ -n "$x" ]; then
+ echo "$x"
+ return 0
+ fi
+ for x in /sbin/"$1" /usr/sbin/"$1" \
+ /usr/pkg/sbin/"$1" /usr/local/sbin/"$1"
+ do
+ if [ -e "$x" ]; then
+ echo "$x"
+ return 0
+ fi
+ done
+ return 1
+}
+
CONFIG_H=config.h
CONFIG_MK=config.mk
fi
rm -f _strlcpy.c _strlcpy
-cd dhcpcd-hooks
HOOKS=
+printf "Checking for ntpd ... "
+NTPD=$(_which ntpd)
+if [ -n "$NTPD" ]; then
+ echo "$NTPD (50-ntp.conf)"
+ HOOKS="$HOOKS${HOOKS:+ }50-ntp.conf"
+else
+ echo "not found"
+fi
+
+printf "Checking for ypind ... "
+YPBIND=$(_which ypbind)
+if [ -n "$YPBIND" ]; then
+ if strings "$YPBIND" | grep -q yp.conf; then
+ YPHOOK="50-yp.conf"
+ else
+ YPHOOK="50-ypbind"
+ fi
+ echo "$YPBIND ($YPHOOK)"
+ HOOKS="$HOOKS${HOOKS:+ }$YPHOOK"
+else
+ echo "not found"
+fi
+
+cd dhcpcd-hooks
for x in $HOOKSCRIPTS; do
printf "Finding hook $x ... "
for h in [0-9][0-9]"-$x" [0-9][0-9]"-$x.sh" [0-9][0-9]"-$x.conf"; do
echo " DBDIR = $DBDIR"
echo " RUNDIR = $RUNDIR"
echo " MANDIR = $MANDIR"
-echo " HOOKSCRIPTS = $HOOKSCRIPTS"
+echo " HOOKSCRIPTS = $HOOKS"
echo
--- /dev/null
+# Sample dhcpcd hook for ypbind
+# This script is only suitable for the Linux version.
+
+# Distributions may want to just have their command here instead of this
+if [ -x /etc/rc.d/ypbind ]; then
+ ypbind_restart_cmd="/etc/rc.d/ypbind restart"
+elif [ -x /usr/local/etc/rc.d/ypbind ]; then
+ ypbind_restart_cmd="/usr/local/etc/rc.d/ypbind restart"
+fi
+
+make_yp_binding()
+{
+ [ -z "$new_nis_domain" ] && return
+
+ 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
+ if change_file "$cf" "$ncf"; then
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+ else
+ if [ -e "$cf" ]; then
+ rm "$cf"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+ fi
+}
+
+restore_yp_binding()
+{
+ [ -z "$old_nis_domain" ] && return
+
+ if restore_conf /var/yp/binding/"$old_nis_domain".ypservers; then
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ elif [ -e /var/yp/binding/"$old_nis_domain".ypservers ]; then
+ rm /var/yp/binding/"$old_nis_domain".ypservers
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+case "$reason" in
+BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC) make_yp_binding;;
+EXPIRE|FAIL|IPV4LL|NAK|NOCARRIER|RELEASE|STOP) restore_yp_binding;;
+esac
import:
${INSTALL} -d /tmp/${DISTPREFIX}/dhcpcd-hooks
- cp ${SCRIPTS} 50-ntp.conf /tmp/${DISTPREFIX}/dhcpcd-hooks
+ ${INSTALL} -m ${NONBINMODE} ${SCRIPTS} /tmp/${DISTPREFIX}/dhcpcd-hooks
+