printf "Checking for ypind ... "
YPBIND=$(_which ypbind)
if [ -n "$YPBIND" ]; then
- if strings "$YPBIND" | $GREP -q yp.conf; then
+ if strings "$YPBIND" | $GREP -q yp\\.conf; then
YPHOOK="50-yp.conf"
- else
+ elif strings "$YPBIND" | $GREP -q \\.ypservers; then
+ YPHOOK="50-ypbind"
+ echo "YPDOMAIN_DIR= /var/yp" >>$CONFIG_MK
+ echo "YPDOMAIN_SUFFIX=.ypservers" >>$CONFIG_MK
+ elif strings "$YPBIND" | $GREP -q /etc/yp; then
YPHOOK="50-ypbind"
+ echo "YPDOMAIN_DIR= /etc/yp" >>$CONFIG_MK
+ echo "YPDOMAIN_SUFFIX=" >>$CONFIG_MK
+ fi
+ if [ -n "$YPHOOK" ]; then
+ echo "$YPBIND ($YPHOOK)"
+ HOOKS="$HOOKS${HOOKS:+ }$YPHOOK"
+ else
+ echo "unsupported version"
fi
- echo "$YPBIND ($YPHOOK)"
- HOOKS="$HOOKS${HOOKS:+ }$YPHOOK"
else
echo "not found"
fi
# Sample dhcpcd hook for ypbind
-# This script is only suitable for the Linux version.
+# This script is only suitable for the NetBSD and OpenBSD versions.
: ${ypbind_restart_cmd:=service_command ypbind restart}
: ${ypbind_stop_cmd:=service_condcommand ypbind stop}
ypbind_dir="$state_dir/ypbind"
+: ${ypdomain_dir:=@YPDOMAIN_DIR@}
+: ${ypdomain_suffix:=@YPDOMAIN_SUFFIX@}
+
best_domain()
{
echo "$new_nis_domain" >"$ypbind_dir/$ifname"
local nd="$(best_domain)"
- local cf=/var/yp/binding/"$new_nis_domain".ypservers
- if [ -n "$new_nis_servers" ]; then
- local ncf="$cf.$ifname" x=
- rm -f "$ncf"
- for x in $new_nis_servers; do
- echo "$x" >>"$ncf"
- done
- change_file "$cf" "$ncf"
+ if [ -z "$ypdomain_dir" ]; then
+ false
else
- # Because this is not an if .. fi then we can use $? below
- [ -e "$cf" ] && rm "$cf"
+ local cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
+ if [ -n "$new_nis_servers" ]; then
+ local ncf="$cf.$ifname" x=
+ rm -f "$ncf"
+ for x in $new_nis_servers; do
+ echo "$x" >>"$ncf"
+ done
+ change_file "$cf" "$ncf"
+ else
+ [ -e "$cf" ] && rm "$cf"
+ fi
fi
if [ $? = 0 -o "$nd" != "$(domainname)" ]; then
restore_yp_binding()
{
+
rm -f "$ypbind_dir/$ifname"
local nd="$(best_domain)"
# We need to stop ypbind if there is no best domain