summaryrefslogtreecommitdiff
blob: 231d266ca4204fbcc0d0b19ef72d2759082ff056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#RCUPDATE:3 4:72:This line is required for script management

. /etc/rc.d/config/functions
. /etc/rc.d/config/basic

SERVICE=ypbind
EXE="/usr/sbin/ypbind"
PID="/var/run/ypbind.pid"
opts="start stop restart"

start() {
	ebegin "Starting ${SERVICE}"
	if [ -n "$YP_DOMAIN" ]
	then


		ypdomainname "$YP_DOMAIN"
		start-stop-daemon --start --quiet --exec $EXE 1>&2
		if [ -n "$?" ]
		then
			notfound=1
			for i in 0 1 2 3 4 5 6 7 8 9
			do
				ypwhich &>/dev/null && { notfound=0; break; };
				sleep 1;
				eend 0 
			done
			if [ $notfound -eq 1 ] 
			then
				eend 1 "No NIS server found"
			else
				eend 0
			fi
		else
			eend $? "Error starting ${SERVICE}."
		fi
	else
		eend 1 "Error starting ${SERVICE}."
	fi
}

stop() {
	if [ -n "$YP_DOMAIN" ]
	then
		ebegin "Stopping ${SERVICE}"
		start-stop-daemon --stop --quiet -s 9 --pid $PID 1>&2
		eend $? "Error stopping ${SERVICE}."
	        # Remove binding files, if ypbind "forget" it
		rm -f /var/yp/binding/*
		rm -f $PID
	fi
}

restart() {
		stop
		start
}

doservice ${@}