1 # Sample dhcpcd hook for ypbind
2 # This script is only suitable for the Linux version.
4 # Distributions may want to just have their command here instead of this
5 if [ -x /etc/rc.d/ypbind ]; then
6 ypbind_restart_cmd="/etc/rc.d/ypbind restart"
7 ypbind_stop_cmd="/etc/rc.d/ypbind stop"
8 elif [ -x /usr/local/etc/rc.d/ypbind ]; then
9 ypbind_restart_cmd="/usr/local/etc/rc.d/ypbind restart"
10 ypbind_stop_cmd="/usr/local/etc/rc.d/ypbind stop"
13 ypbind_dir="$state_dir/ypbind"
19 for i in $interfaces; do
20 if [ -e "$ypbind_dir/$i" ]; then
29 [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
30 echo "$new_nis_domain" >"$ypbind_dir/$interface"
31 local nd="$(best_domain)"
33 local cf=/var/yp/binding/"$new_nis_domain".ypservers
34 if [ -n "$new_nis_servers" ]; then
35 local ncf="$cf.$interface" x=
37 for x in $new_nis_servers; do
40 change_file "$cf" "$ncf"
42 # Because this is not an if .. fi then we can use $? below
43 [ -e "$cf" ] && rm "$cf"
46 if [ $? = 0 -o "$nd" != "$(domainname)" ]; then
48 if [ -n "$ypbind_restart_cmd" ]; then
49 eval $ypbind_restart_cmd
56 rm -f "$ypbind_dir/$interface"
57 local nd="$(best_domain)"
58 # We need to stop ypbind if there is no best domain
59 # otherwise it will just stall as we cannot set domainname
62 if [ -n "$ypbind_stop_cmd" ]; then
65 elif [ "$nd" != "$(domainname)" ]; then
67 if [ -n "$ypbind_restart_cmd" ]; then
68 eval $ypbind_restart_cmd
75 rm -f "$ypbind_dir/$interface"
80 if [ -n "$new_nis_domain" ]; then
82 elif [ -n "$old_nis_domain" ]; then