1 # Sample dhcpcd hook for ypbind
2 # This script is only suitable for the BSD versions.
4 : ${ypbind_restart_cmd:=service_command ypbind restart}
5 : ${ypbind_stop_cmd:=service_condcommand ypbind stop}
6 ypbind_dir="$state_dir/ypbind"
12 for i in "$ypbind_dir/$interface_order".*; do
23 [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
24 echo "$new_nis_domain" >"$ypbind_dir/$ifname"
26 if [ -z "$ypdomain_dir" ]; then
29 cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
30 if [ -n "$new_nis_servers" ]; then
33 for x in $new_nis_servers; do
36 change_file "$cf" "$ncf"
38 [ -e "$cf" ] && rm "$cf"
43 if [ $? = 0 ] && [ "$nd" != "$(domainname)" ]; then
45 if [ -n "$ypbind_restart_cmd" ]; then
46 eval $ypbind_restart_cmd
53 rm -f "$ypbind_dir/$ifname"
55 # We need to stop ypbind if there is no best domain
56 # otherwise it will just stall as we cannot set domainname
59 if [ -n "$ypbind_stop_cmd" ]; then
62 elif [ "$nd" != "$(domainname)" ]; then
64 if [ -n "$ypbind_restart_cmd" ]; then
65 eval $ypbind_restart_cmd
70 if ! $if_configured; then
72 elif [ "$reason" = PREINIT ]; then
73 rm -f "$ypbind_dir/$interface".*
74 elif $if_up || $if_down; then
75 if [ -n "$new_nis_domain" ]; then
76 if valid_domainname "$new_nis_domain"; then
79 syslog err "Invalid NIS domain name: $new_nis_domain"
81 elif [ -n "$old_nis_domain" ]; then