aboutsummaryrefslogtreecommitdiffstats
path: root/dhcpcd-hooks/50-ypbind
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-01-24 16:27:51 -0800
committerDmitry Shmidt <dimitrysh@google.com>2011-01-24 16:27:51 -0800
commite86eee143ed21592f88a46623a81f71002430459 (patch)
treee0be4ce113729bce176fd5054aeaf51a88b2e169 /dhcpcd-hooks/50-ypbind
parent6bcc301d166624837871fd601b4d3b5d43551e6b (diff)
downloadexternal_dhcpcd-e86eee143ed21592f88a46623a81f71002430459.zip
external_dhcpcd-e86eee143ed21592f88a46623a81f71002430459.tar.gz
external_dhcpcd-e86eee143ed21592f88a46623a81f71002430459.tar.bz2
dhcpcd: Update to Version 5.2.10
Change-Id: I949331c7aad91b125decd51da4041983d3a352bc Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'dhcpcd-hooks/50-ypbind')
-rw-r--r--dhcpcd-hooks/50-ypbind74
1 files changed, 74 insertions, 0 deletions
diff --git a/dhcpcd-hooks/50-ypbind b/dhcpcd-hooks/50-ypbind
new file mode 100644
index 0000000..9a1fecc
--- /dev/null
+++ b/dhcpcd-hooks/50-ypbind
@@ -0,0 +1,74 @@
+# Sample dhcpcd hook for ypbind
+# This script is only suitable for the Linux version.
+
+: ${ypbind_restart_cmd:=service_command ypbind restart}
+: ${ypbind_stop_cmd:=service_condcommand ypbind stop}
+ypbind_dir="$state_dir/ypbind"
+
+best_domain()
+{
+ local i=
+
+ for i in $interfaces; do
+ if [ -e "$ypbind_dir/$i" ]; then
+ cat "$ypbind_dir/$i"
+ fi
+ done
+ return 1
+}
+
+make_yp_binding()
+{
+ [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
+ echo "$new_nis_domain" >"$ypbind_dir/$interface"
+ local nd="$(best_domain)"
+
+ local cf=/var/yp/binding/"$new_nis_domain".ypservers
+ if [ -n "$new_nis_servers" ]; then
+ local ncf="$cf.$interface" x=
+ rm -f "$ncf"
+ for x in $new_nis_servers; do
+ echo "$x" >>"$ncf"
+ done
+ change_file "$cf" "$ncf"
+ else
+ # Because this is not an if .. fi then we can use $? below
+ [ -e "$cf" ] && rm "$cf"
+ fi
+
+ if [ $? = 0 -o "$nd" != "$(domainname)" ]; then
+ domainname "$nd"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+restore_yp_binding()
+{
+ rm -f "$ypbind_dir/$interface"
+ local nd="$(best_domain)"
+ # We need to stop ypbind if there is no best domain
+ # otherwise it will just stall as we cannot set domainname
+ # to blank :/
+ if [ -z "$nd" ]; then
+ if [ -n "$ypbind_stop_cmd" ]; then
+ eval $ypbind_stop_cmd
+ fi
+ elif [ "$nd" != "$(domainname)" ]; then
+ domainname "$nd"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+if [ "$reason" = PREINIT ]; then
+ rm -f "$ypbind_dir/$interface"
+elif $if_up || $if_down; then
+ if [ -n "$new_nis_domain" ]; then
+ make_yp_binding
+ elif [ -n "$old_nis_domain" ]; then
+ restore_yp_binding
+ fi
+fi