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@}
15
for i in "$ypbind_dir/$interface_order".*; do
26
[ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
27
echo "$new_nis_domain" >"$ypbind_dir/$ifname"
29
if [ -z "$ypdomain_dir" ]; then
32
local cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
33
if [ -n "$new_nis_servers" ]; then
34
local ncf="$cf.$ifname" x=
36
for x in $new_nis_servers; do
39
change_file "$cf" "$ncf"
41
[ -e "$cf" ] && rm "$cf"
45
local nd="$(best_domain)"
46
if [ $? = 0 -a "$nd" != "$(domainname)" ]; then
48
if [ -n "$ypbind_restart_cmd" ]; then
49
eval $ypbind_restart_cmd
57
rm -f "$ypbind_dir/$ifname"
58
local nd="$(best_domain)"
59
# We need to stop ypbind if there is no best domain
60
# otherwise it will just stall as we cannot set domainname
63
if [ -n "$ypbind_stop_cmd" ]; then
66
elif [ "$nd" != "$(domainname)" ]; then
68
if [ -n "$ypbind_restart_cmd" ]; then
69
eval $ypbind_restart_cmd
74
if [ "$reason" = PREINIT ]; then
75
rm -f "$ypbind_dir/$interface".*
76
elif $if_up || $if_down; then
77
if [ -n "$new_nis_domain" ]; then
78
if valid_domainname "$new_nis_domain"; then
81
syslog err "Invalid NIS domain name: $new_nis_domain"
83
elif [ -n "$old_nis_domain" ]; then