hc
2023-12-06 d38611ca164021d018c1b23eee65bbebc09c63e0
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#! /bin/sh
# Copyright (c) 2004 Author: Thorsten Kukuk <kukuk@suse.de>
#
# /etc/init.d/ypbind
#
#   and symbolic its link
#
# /usr/sbin/rcypbind
#
# System startup script for the ypbind daemon
#
### BEGIN INIT INFO
# Provides: ypbind
# Required-Start: $remote_fs $portmap
# Should-Start: ypserv slpd
# Required-Stop: portmap
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Start ypbind (necessary for a NIS client)
# Description: ypbind finds the server for NIS domains and maintains
#    the NIS binding information.
### END INIT INFO
 
# Need to use status function
. /etc/init.d/functions
 
YPBIND_BIN=/usr/sbin/ypbind
pidfile=/var/run/ypbind.pid
YPDOMAINNAME_bin=/usr/bin/ypdomainname
 
[ -f /etc/default/ypbind ] && . /etc/default/ypbind
 
case "$1" in
    start)
   echo -n "Starting ypbind"
   ## If the domainname is not set, skip starting of ypbind
   ## and return with "program not configured"
        $YPDOMAINNAME_bin >/dev/null 2>&1
        if [ $? -ne 0 -o -z "`$YPDOMAINNAME_bin 2>/dev/null`" ]; then
           if [ -f /etc/defaultdomain ]; then
             XDOMAINNAME=`cat /etc/defaultdomain`
             $YPDOMAINNAME_bin "$XDOMAINNAME"
      fi
           $YPDOMAINNAME_bin >/dev/null 2>&1
           if [ $? -ne 0 -o -z "`$YPDOMAINNAME_bin 2>/dev/null`" ]; then
        # Tell the user this has skipped
        echo -n " . . . . . . . . . . No domainname set"
             # service is not configured
        exit 1
           fi
        fi
 
   ## If we don't have a /etc/yp.conf file, skip starting of
        ## ypbind and return with "program not configured"
        ## if you add the -broadcast Option later, comment this out.
   if [ ! -f /etc/yp.conf -a "$YPBIND_BROADCAST" != "yes" ] ; then
     # Tell the user this has skipped
     echo -n " . . . . . . . . . . ${attn}/etc/yp.conf not found${norm}"
          # service is not configured
     exit 1
        fi
 
   # evaluate the OPTIONS for ypbind-mt
   OPTIONS=""
   test "$YPBIND_LOCAL_ONLY" = "yes" && OPTIONS="-local-only $OPTIONS"
   test "$YPBIND_BROADCAST" = "yes" && OPTIONS="-broadcast $OPTIONS"
   test "$YPBIND_BROKEN_SERVER" = "yes" && OPTIONS="-broken-server $OPTIONS"
 
   start-stop-daemon --start --quiet --pidfile $pidfile --exec $YPBIND_BIN -- $YPBIND_OPTIONS $OPTIONS
        if [ $? -eq 0 ]; then
            notfound=1
            for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
                ypwhich >/dev/null 2>&1 && { notfound=0 ; break; };
                echo -n " ."
                sleep 1;
            done
            if [ $notfound -eq 1 ]; then
                echo -n " ${warn}No NIS server found${norm}";
       fi
        else
            exit 1
        fi
   ;;
    stop)
   echo -n "Shutting down ypbind"
   start-stop-daemon --stop --quiet --pidfile $pidfile
   # Remove static data, else glibc will continue to use NIS
        rm -f /var/yp/binding/* /var/run/ypbind.pid
   ;;
    restart)
   $0 stop
   sleep 1
   $0 start
   ;;
    reload | force-reload)
   echo -n "Reload service ypbind"
   start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile
   ;;
    status)
   echo -n "Checking for ypbind: "
   status $YPBIND_BIN
   ;;
    *)
   echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
   exit 1
   ;;
esac