]> git.saurik.com Git - apple/launchd.git/blob - launchd/src/StartupItems/NIS
launchd-106.tar.gz
[apple/launchd.git] / launchd / src / StartupItems / NIS
1 #!/bin/sh
2
3 ##
4 # Network Information Service
5 ##
6
7 . /etc/rc.common
8
9
10 Startyppasswdd()
11 {
12 # rpc.yppasswdd is run on NIS masters
13 if [ -f "${VARYP}/${NISDOMAIN}/ypservers.db" ]; then
14 NISMASTER=$(makedbm -U "${VARYP}/${NISDOMAIN}/ypservers" | sed -n '/YP_MASTER_NAME/p' | awk '{print $2}')
15 if [ "$NISMASTER" = "$(hostname)" ]; then
16 rpc.yppasswdd
17 fi
18 fi
19 }
20
21 StartService ()
22 {
23 ##
24 # Network Information Service.
25 ##
26 CheckForNetwork
27 if [ -f /var/run/NIS.StartupItem -o "${NETWORKUP}" = "-NO-" ]; then exit; fi
28 touch /var/run/NIS.StartupItem
29
30 if [ "${NISDOMAIN:=-NO-}" != "-NO-" ]; then
31
32 VARYP=/var/yp
33
34 echo "Starting Network Information Service"
35
36 echo "Setting NIS domainname to ${NISDOMAIN}"
37 domainname "${NISDOMAIN}"
38
39 # ypserv is run on NIS servers - machines with an ${VARYP}/${NISDOMAIN} dir
40 if [ -d "${VARYP}/${NISDOMAIN}" ]; then
41 if ! pid=$(GetPID ypserv); then
42 ypserv
43 fi
44 fi
45
46 Startyppasswdd
47
48 # ypbind is run on all NIS clients
49 ypbind
50 fi
51 }
52
53 StopService ()
54 {
55 echo "Stopping Network Information Service"
56 killall -TERM ypbind > /dev/null 2>&1
57 killall -TERM rpc.yppasswdd > /dev/null 2>&1
58
59 if pid=$(GetPID ypserv); then
60 kill -TERM "${pid}"
61 fi
62 }
63
64 RestartService ()
65 {
66 echo "Restarting Network Information Service"
67 killall -TERM ypbind > /dev/null 2>&1
68 killall -TERM rpc.yppasswdd > /dev/null 2>&1
69
70 if pid=$(GetPID ypserv); then
71 kill -HUP "${pid}"
72 Startyppasswdd
73 ypbind
74 else
75 StartService
76 fi
77 }
78
79 RunService "$1"