From: Roy Marples Date: Wed, 19 Mar 2014 15:02:30 +0000 (+0000) Subject: Support ypbind on OpenBSD. X-Git-Tag: v6.4.0~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1f24bd93857dd8528cf557160b43126d822974e;p=thirdparty%2Fdhcpcd.git Support ypbind on OpenBSD. --- diff --git a/configure b/configure index 82fae317..39e8128a 100755 --- a/configure +++ b/configure @@ -787,13 +787,23 @@ if ! $HOOKSET; then 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 diff --git a/dhcpcd-hooks/50-ypbind b/dhcpcd-hooks/50-ypbind.in similarity index 74% rename from dhcpcd-hooks/50-ypbind rename to dhcpcd-hooks/50-ypbind.in index 25e009d7..c0ac104b 100644 --- a/dhcpcd-hooks/50-ypbind +++ b/dhcpcd-hooks/50-ypbind.in @@ -1,9 +1,12 @@ # 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() { @@ -23,17 +26,20 @@ make_yp_binding() 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 @@ -46,6 +52,7 @@ make_yp_binding() restore_yp_binding() { + rm -f "$ypbind_dir/$ifname" local nd="$(best_domain)" # We need to stop ypbind if there is no best domain diff --git a/dhcpcd-hooks/Makefile b/dhcpcd-hooks/Makefile index 5982f1b7..fab39efe 100644 --- a/dhcpcd-hooks/Makefile +++ b/dhcpcd-hooks/Makefile @@ -8,9 +8,16 @@ SCRIPTS+= 10-mtu 10-wpa_supplicant 15-timezone 20-resolv.conf SCRIPTS+= 29-lookup-hostname 30-hostname SCRIPTS+= ${HOOKSCRIPTS} -all: +50-ypbind: 50-ypbind.in + ${SED} \ + -e 's:@YPDOMAIN_DIR@:${YPDOMAIN_DIR}:g' \ + -e 's:@YPDOMAIN_SUFFIX@:${YPDOMAIN_SUFFIX}:g' \ + 50-ypbind.in > $@ + +all: ${HOOKSCRIPTS} clean: + rm -f 50-ypbind proginstall: ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}