1 # Sample dhcpcd hook for ypbind 2 # This script is only suitable for the Linux version. 3 4 ypbind_pid() 5 { 6 [ -s /var/run/ypbind.pid ] && cat /var/run/ypbind.pid 7 } 8 9 make_yp_conf() 10 { 11 [ -z "$new_nis_domain" -a -z "$new_nis_servers" ] && return 0 12 local cf=/etc/yp.conf."$interface" prefix= x= pid= 13 rm -f "$cf" 14 echo "$signature" > "$cf" 15 if [ -n "$new_nis_domain" ]; then 16 domainname "$new_nis_domain" 17 if [ -n "$new_nis_servers" ]; then 18 prefix="domain $new_nis_domain server " 19 else 20 echo "domain $new_nis_domain broadcast" >> "$cf" 21 fi 22 else 23 prefix="ypserver " 24 fi 25 for x in $new_nis_servers; do 26 echo "$prefix$x" >> "$cf" 27 done 28 save_conf /etc/yp.conf 29 cat "$cf" > /etc/yp.conf 30 rm -f "$cf" 31 pid="$(ypbind_pid)" 32 if [ -n "$pid" ]; then 33 kill -HUP "$pid" 34 fi 35 } 36 37 restore_yp_conf() 38 { 39 [ -n "$old_nis_domain" ] && domainname "" 40 restore_conf /etc/yp.conf || return 0 41 local pid="$(ypbind_pid)" 42 if [ -n "$pid" ]; then 43 kill -HUP "$pid" 44 fi 45 } 46 47 if $if_up; then 48 make_yp_conf 49 elif $if_down; then 50 restore_yp_conf 51 fi 52