• 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."${interface}" prefix= x= pid=
13	rm -f "${cf}"
14	echo "${signature}" > "${cf}"
15	if [ -n "${new_nis_domain}" ]; then
16		domainname "${new_nis_domain}"
17		if [ -n "${new_nis_servers}" ]; then
18			prefix="domain ${new_nis_domain} server "
19		else
20			echo "domain ${new_nis_domain} broadcast" >> "${cf}"
21		fi
22	else
23		prefix="ypserver "
24	fi
25	for x in ${new_nis_servers}; do
26		echo "${prefix}${x}" >> "${cf}"
27	done
28	save_conf /etc/yp.conf
29	mv -f "${cf}" /etc/yp.conf
30	pid="$(ypbind_pid)"
31	if [ -n "${pid}" ]; then
32		kill -HUP "${pid}"
33	fi
34}
35
36restore_yp_conf()
37{
38	[ -n "${old_nis_domain}" ] && domainname ""
39	restore_conf /etc/yp.conf || return 0
40	local pid="$(ypbind_pid)"
41	if [ -n "${pid}" ]; then
42		kill -HUP "${pid}"
43	fi
44}
45
46case "${reason}" in
47BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT)	make_yp_conf;;
48EXPIRE|FAIL|IPV4LL|RELEASE|STOP)		restore_yp_conf;;
49esac
50