~ubuntu-branches/ubuntu/oneiric/nis/oneiric-proposed

« back to all changes in this revision

Viewing changes to ypbind-mt-1.19.1/etc/ypbind.init

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2005-11-16 23:42:06 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20051116234206-p00omaw5ji5q0qhr
Tags: 3.15-3ubuntu1
Resynchronise with Debian.  (me)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
YPBIND_BIN=/usr/sbin/ypbind
 
25
test -x $YPBIND_BIN || { echo "$YPBIND_BIN not installed";
 
26
        if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; }
 
27
 
 
28
YPBIND_CONFIG=/etc/sysconfig/ypbind
 
29
test -r $YPBIND_CONFIG || { echo "$YPBIND_CONFIG not existing";
 
30
        if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; }
 
31
 
 
32
# Read config
 
33
. $YPBIND_CONFIG
 
34
 
 
35
. /etc/rc.status
 
36
 
 
37
# First reset status of this service
 
38
rc_reset
 
39
 
 
40
# Return values acc. to LSB for all commands but status:
 
41
# 0 - success
 
42
# 1 - misc error
 
43
# 2 - invalid or excess args
 
44
# 3 - unimplemented feature (e.g. reload)
 
45
# 4 - insufficient privilege
 
46
# 5 - program not installed
 
47
# 6 - program not configured
 
48
#
 
49
# Note that starting an already running service, stopping
 
50
# or restarting a not-running service as well as the restart
 
51
# with force-reload (in case signalling is not supported) are
 
52
# considered a success.
 
53
 
 
54
case "$1" in
 
55
    start)
 
56
        echo -n "Starting ypbind"
 
57
        ## If the domainname is not set, skip starting of ypbind
 
58
        ## and return with "program not configured"
 
59
        /bin/ypdomainname &> /dev/null
 
60
        if [ $? -ne 0 -o -z "`/bin/ypdomainname 2>/dev/null`" ]; then
 
61
           if [ -f /etc/defaultdomain ]; then
 
62
             XDOMAINNAME=`cat /etc/defaultdomain`
 
63
             /bin/ypdomainname "$XDOMAINNAME"
 
64
           fi
 
65
           /bin/ypdomainname &> /dev/null
 
66
           if [ $? -ne 0 -o -z "`/bin/ypdomainname 2>/dev/null`" ]; then
 
67
             # Tell the user this has skipped
 
68
             echo -n " . . . . . . . . . . No domainname set"
 
69
             rc_status -s
 
70
             # service is not configured
 
71
             rc_failed 6
 
72
             rc_exit
 
73
           fi
 
74
        fi
 
75
 
 
76
        ## If we don't have a /etc/yp.conf file, skip starting of
 
77
        ## ypbind and return with "program not configured"
 
78
        ## if you add the -broadcast Option later, comment this out.
 
79
        if [ ! -f /etc/yp.conf -a "$YPBIND_BROADCAST" != "yes" ] ; then
 
80
          # Tell the user this has skipped
 
81
          echo -n " . . . . . . . . . . ${attn}/etc/yp.conf not found${norm}"
 
82
          rc_status -s
 
83
          # service is not configured
 
84
          rc_failed 6
 
85
          rc_exit
 
86
        fi
 
87
 
 
88
        ## Check if portmap is running, else abort with error
 
89
        checkproc /sbin/portmap
 
90
        if [ $? -ne 0 ]; then
 
91
          echo -n " . . . . . . . . . . ${attn}No portmapper running${norm}"
 
92
          rc_failed
 
93
          rc_status -v
 
94
          rc_exit
 
95
        fi
 
96
 
 
97
        # evaluate the OPTIONS for ypbind-mt
 
98
        OPTIONS=""
 
99
        test "$YPBIND_LOCAL_ONLY" = "yes" && OPTIONS="-local-only $OPTIONS"
 
100
        test "$YPBIND_BROADCAST" = "yes" && OPTIONS="-broadcast $OPTIONS"
 
101
        test "$YPBIND_BROKEN_SERVER" = "yes" && OPTIONS="-broken-server $OPTIONS"
 
102
 
 
103
        startproc $YPBIND_BIN $YPBIND_OPTIONS $OPTIONS
 
104
        if [ $? -eq 0 ]; then
 
105
            notfound=1
 
106
            for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
 
107
                ypwhich &>/dev/null && { notfound=0 ; break; };
 
108
                echo -n " ."
 
109
                sleep 1;
 
110
            done
 
111
            if [ $notfound -eq 1 ]; then
 
112
                echo -n " ${warn}No NIS server found${norm}";
 
113
            fi
 
114
        else
 
115
            rc_failed
 
116
        fi
 
117
        rc_status -v
 
118
        ;;
 
119
    stop)
 
120
        echo -n "Shutting down ypbind"
 
121
        killproc -TERM $YPBIND_BIN
 
122
        # Remove static data, else glibc will continue to use NIS
 
123
        rm -f /var/yp/binding/* /var/run/ypbind.pid
 
124
        rc_status -v
 
125
        ;;
 
126
    try-restart|condrestart)
 
127
        ## Do a restart only if the service was active before.
 
128
        ## Note: try-restart is now part of LSB (as of 1.9).
 
129
        ## RH has a similar command named condrestart.
 
130
        if test "$1" = "condrestart"; then
 
131
                echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
 
132
        fi
 
133
        $0 status
 
134
        if test $? = 0; then
 
135
                $0 restart
 
136
        else
 
137
                rc_reset        # Not running is not a failure.
 
138
        fi
 
139
        rc_status
 
140
        ;;
 
141
    restart)
 
142
        $0 stop
 
143
        sleep 1
 
144
        $0 start
 
145
        rc_status
 
146
        ;;
 
147
    force-reload)
 
148
        echo -n "Reload service ypbind"
 
149
        killproc -HUP $YPBIND_BIN
 
150
        rc_status -v
 
151
        ;;
 
152
    reload)
 
153
        echo -n "Reload service ypbind"
 
154
        killproc -HUP $YPBIND_BIN
 
155
        rc_status -v
 
156
        ;;
 
157
    status)
 
158
        echo -n "Checking for ypbind: "
 
159
        checkproc $YPBIND_BIN
 
160
        rc_status -v
 
161
        ;;
 
162
    probe)
 
163
        if [ /etc/yp.conf -nt /var/run/ypbind.pid ]; then
 
164
          echo reload
 
165
        elif [ $YPBIND_CONFIG -nt /var/run/ypbind.pid ]; then
 
166
          echo restart
 
167
        fi
 
168
        ;;
 
169
    *)
 
170
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
 
171
        exit 1
 
172
        ;;
 
173
esac
 
174
rc_exit