"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/extras/init.d/glustereventsd-Redhat" (16 Sep 2020, 2318 Bytes) of package /linux/misc/glusterfs-8.2.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.

    1 #!/bin/bash
    2 #
    3 # glustereventsd   Startup script for the glusterfs Events server
    4 #
    5 # chkconfig:   - 20 80
    6 # description: Gluster Events Server
    7 
    8 ### BEGIN INIT INFO
    9 # Provides: glustereventsd
   10 # Required-Start: $local_fs $network
   11 # Required-Stop: $local_fs $network
   12 # Should-Start:
   13 # Should-Stop:
   14 # Default-Start: 2 3 4 5
   15 # Default-Stop: 0 1 6
   16 # Short-Description: glusterfs Events server
   17 # Description:       GlusterFS Events Server
   18 ### END INIT INFO
   19 #
   20 
   21 # Source function library.
   22 . /etc/rc.d/init.d/functions
   23 
   24 BASE=glustereventsd
   25 
   26 # Fedora File System Layout dictates /run
   27 [ -e /run ] && RUNDIR="/run"
   28 PIDFILE="${RUNDIR:-/var/run}/${BASE}.pid"
   29 
   30 PID=`test -f $PIDFILE && cat $PIDFILE`
   31 
   32 GLUSTEREVENTSD_BIN=/usr/local/sbin/$BASE
   33 GLUSTEREVENTSD_OPTS="--pid-file=$PIDFILE"
   34 GLUSTEREVENTSD="$GLUSTEREVENTSD_BIN $GLUSTEREVENTSD_OPTS"
   35 RETVAL=0
   36 
   37 LOCKFILE=/var/lock/subsys/${BASE}
   38 
   39 # Start the service $BASE
   40 start()
   41 {
   42        if pidofproc -p $PIDFILE $GLUSTEREVENTSD_BIN &> /dev/null; then
   43            echo "glustereventsd service is already running with pid $PID"
   44            return 0
   45        else
   46            echo -n $"Starting $BASE:"
   47            daemon $GLUSTEREVENTSD &
   48            RETVAL=$?
   49            echo
   50            [ $RETVAL -eq 0 ] && touch $LOCKFILE
   51            return $RETVAL
   52        fi
   53 }
   54 
   55 # Stop the service $BASE
   56 stop()
   57 {
   58     echo -n $"Stopping $BASE:"
   59     if pidofproc -p $PIDFILE $GLUSTEREVENTSD_BIN &> /dev/null; then
   60         killproc -p $PIDFILE $BASE
   61     else
   62         killproc $BASE
   63     fi
   64     RETVAL=$?
   65     echo
   66     [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
   67     return $RETVAL
   68 }
   69 
   70 restart()
   71 {
   72     stop
   73     start
   74 }
   75 
   76 reload()
   77 {
   78     restart
   79 }
   80 
   81 force_reload()
   82 {
   83     restart
   84 }
   85 
   86 rh_status()
   87 {
   88     status $BASE
   89 }
   90 
   91 rh_status_q()
   92 {
   93     rh_status &>/dev/null
   94 }
   95 
   96 
   97 ### service arguments ###
   98 case $1 in
   99     start)
  100         rh_status_q && exit 0
  101         $1
  102         ;;
  103     stop)
  104         rh_status_q || exit 0
  105         $1
  106         ;;
  107     restart)
  108         $1
  109         ;;
  110     reload)
  111         rh_status_q || exit 7
  112         $1
  113         ;;
  114     force-reload)
  115         force_reload
  116         ;;
  117     status)
  118         rh_status
  119         ;;
  120     condrestart|try-restart)
  121         rh_status_q || exit 0
  122         restart
  123         ;;
  124     *)
  125         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
  126         exit 1
  127 esac
  128 
  129 exit $?