"Fossies" - the Fresh Open Source Software Archive

Member "ypbind-mt-2.4/etc/ypbind.init" (24 Apr 2015, 4238 Bytes) of archive /linux/misc/ypbind-mt-2.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "ypbind.init": 2.0_vs_2.2.

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