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"
7 : ${ypdomain_dir:=@YPDOMAIN_DIR@}
8 : ${ypdomain_suffix:=@YPDOMAIN_SUFFIX@}
13 for i in "$ypbind_dir/$interface_order".*; do
24 [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
25 echo "$new_nis_domain" >"$ypbind_dir/$ifname"
27 if [ -z "$ypdomain_dir" ]; then
30 cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
31 if [ -n "$new_nis_servers" ]; then
34 for x in $new_nis_servers; do
37 change_file "$cf" "$ncf"
39 [ -e "$cf" ] && rm "$cf"
44 if [ $? = 0 -a "$nd" != "$(domainname)" ]; then
46 if [ -n "$ypbind_restart_cmd" ]; then
47 eval $ypbind_restart_cmd
54 rm -f "$ypbind_dir/$ifname"
56 # We need to stop ypbind if there is no best domain
57 # otherwise it will just stall as we cannot set domainname
60 if [ -n "$ypbind_stop_cmd" ]; then
63 elif [ "$nd" != "$(domainname)" ]; then
65 if [ -n "$ypbind_restart_cmd" ]; then
66 eval $ypbind_restart_cmd
71 if [ "$reason" = PREINIT ]; then
72 rm -f "$ypbind_dir/$interface".*
73 elif $if_up || $if_down; then
74 if [ -n "$new_nis_domain" ]; then
75 if valid_domainname "$new_nis_domain"; then
78 syslog err "Invalid NIS domain name: $new_nis_domain"
80 elif [ -n "$old_nis_domain" ]; then