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