xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-networking/recipes-support/nis/files/ypbind.init (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#! /bin/sh
2# Copyright (c) 2004 Author: Thorsten Kukuk <kukuk@suse.de>
3#
4# /etc/init.d/ypbind
5#
6#   and symbolic its link
7#
8# /usr/sbin/rcypbind
9#
10# System startup script for the ypbind daemon
11#
12### BEGIN INIT INFO
13# Provides: ypbind
14# Required-Start: $remote_fs $portmap
15# Should-Start: ypserv slpd
16# Required-Stop: portmap
17# Default-Start: 3 5
18# Default-Stop: 0 1 2 6
19# Short-Description: Start ypbind (necessary for a NIS client)
20# Description: ypbind finds the server for NIS domains and maintains
21#	the NIS binding information.
22### END INIT INFO
23
24# Need to use status function
25. /etc/init.d/functions
26
27YPBIND_BIN=/usr/sbin/ypbind
28pidfile=/var/run/ypbind.pid
29YPDOMAINNAME_bin=/usr/bin/ypdomainname
30
31[ -f /etc/default/ypbind ] && . /etc/default/ypbind
32
33case "$1" in
34    start)
35	echo -n "Starting ypbind"
36	## If the domainname is not set, skip starting of ypbind
37	## and return with "program not configured"
38        $YPDOMAINNAME_bin >/dev/null 2>&1
39        if [ $? -ne 0 -o -z "`$YPDOMAINNAME_bin 2>/dev/null`" ]; then
40           if [ -f /etc/defaultdomain ]; then
41             XDOMAINNAME=`cat /etc/defaultdomain`
42             $YPDOMAINNAME_bin "$XDOMAINNAME"
43	   fi
44           $YPDOMAINNAME_bin >/dev/null 2>&1
45           if [ $? -ne 0 -o -z "`$YPDOMAINNAME_bin 2>/dev/null`" ]; then
46	     # Tell the user this has skipped
47	     echo -n " . . . . . . . . . . No domainname set"
48             # service is not configured
49	     exit 1
50           fi
51        fi
52
53	## If we don't have a /etc/yp.conf file, skip starting of
54        ## ypbind and return with "program not configured"
55        ## if you add the -broadcast Option later, comment this out.
56	if [ ! -f /etc/yp.conf -a "$YPBIND_BROADCAST" != "yes" ] ; then
57	  # Tell the user this has skipped
58	  echo -n " . . . . . . . . . . ${attn}/etc/yp.conf not found${norm}"
59          # service is not configured
60	  exit 1
61        fi
62
63	# evaluate the OPTIONS for ypbind-mt
64	OPTIONS=""
65	test "$YPBIND_LOCAL_ONLY" = "yes" && OPTIONS="-local-only $OPTIONS"
66	test "$YPBIND_BROADCAST" = "yes" && OPTIONS="-broadcast $OPTIONS"
67	test "$YPBIND_BROKEN_SERVER" = "yes" && OPTIONS="-broken-server $OPTIONS"
68
69	start-stop-daemon --start --quiet --pidfile $pidfile --exec $YPBIND_BIN -- $YPBIND_OPTIONS $OPTIONS
70        if [ $? -eq 0 ]; then
71            notfound=1
72            for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
73                ypwhich >/dev/null 2>&1 && { notfound=0 ; break; };
74                echo -n " ."
75                sleep 1;
76            done
77            if [ $notfound -eq 1 ]; then
78                echo -n " ${warn}No NIS server found${norm}";
79	    fi
80        else
81            exit 1
82        fi
83	;;
84    stop)
85	echo -n "Shutting down ypbind"
86	start-stop-daemon --stop --quiet --pidfile $pidfile
87	# Remove static data, else glibc will continue to use NIS
88        rm -f /var/yp/binding/* /var/run/ypbind.pid
89	;;
90    restart)
91	$0 stop
92	sleep 1
93	$0 start
94	;;
95    reload | force-reload)
96	echo -n "Reload service ypbind"
97	start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile
98	;;
99    status)
100	echo -n "Checking for ypbind: "
101	status $YPBIND_BIN
102	;;
103    *)
104	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
105	exit 1
106	;;
107esac
108