]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Support ypbind on OpenBSD.
authorRoy Marples <roy@marples.name>
Wed, 19 Mar 2014 15:02:30 +0000 (15:02 +0000)
committerRoy Marples <roy@marples.name>
Wed, 19 Mar 2014 15:02:30 +0000 (15:02 +0000)
configure
dhcpcd-hooks/50-ypbind.in [moved from dhcpcd-hooks/50-ypbind with 74% similarity]
dhcpcd-hooks/Makefile

index 82fae317767a8fb2aaf82e88c5905917d2381b9b..39e8128adfb40f811da90758d9c6cba234917322 100755 (executable)
--- 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
similarity index 74%
rename from dhcpcd-hooks/50-ypbind
rename to dhcpcd-hooks/50-ypbind.in
index 25e009d7fc2bc88143ea57cdc66db8875e4c2aa8..c0ac104b328ed309864580aa4af73725e6c5e2fa 100644 (file)
@@ -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
index 5982f1b7d0ffb563eca71a8ba792193f1a6abe77..fab39efe09ebcc471145fe7f4edfe431165403cf 100644 (file)
@@ -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}