"Fossies" - the Fresh Open Source Software Archive

Member "vnstat-2.9/examples/init.d/redhat/vnstat" (16 May 2019, 1472 Bytes) of package /linux/misc/vnstat-2.9.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 and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /bin/sh
    2 #
    3 # chkconfig: 2345 20 50
    4 # description: vnStat - a lightweight network traffic monitor
    5 # processname: vnstatd
    6 # config: /etc/vnstat.conf
    7 
    8 ### BEGIN INIT INFO
    9 # Provides:          vnstat
   10 # Required-Start:    $local_fs $remote_fs $network
   11 # Required-Stop:     $local_fs $remote_fs $network
   12 # Default-Start:     2 3 4 5
   13 # Default-Stop:      0 1 6
   14 # Short-Description: lightweight network traffic monitor
   15 ### END INIT INFO
   16 
   17 VNSTATD_BIN=/usr/sbin/vnstatd
   18 
   19 [ -x $VNSTATD_BIN ] || exit 0
   20 
   21 # Source function library
   22 . /etc/rc.d/init.d/functions
   23 
   24 RETVAL=0
   25 prog=vnstatd
   26 pidfile=/var/run/vnstat/vnstat.pid
   27 
   28 start()
   29 {
   30     echo -n $"Starting $prog: "
   31     if [ -e "$pidfile" ] && [ -e /proc/`cat "$pidfile"` ]; then
   32         echo -n $"already running.";
   33         success "$prog is already running.";
   34         echo
   35         return 0
   36     fi
   37     daemon $VNSTATD_BIN -d
   38     RETVAL=$?
   39     echo
   40     return $RETVAL
   41 }
   42 
   43 stop()
   44 {
   45     echo -n $"Shutting down $prog: "
   46     killproc $VNSTATD_BIN
   47     RETVAL=$?
   48     echo
   49     rm -f $pidfile
   50     return $RETVAL
   51 }
   52 
   53 reload()
   54 {
   55     echo -n $"Reloading $prog configuration: "
   56     killproc $VNSTATD_BIN -HUP
   57     RETVAL=$?
   58     echo
   59     return $RETVAL
   60 }
   61 
   62 case "$1" in
   63     start)
   64         start
   65         ;;
   66     stop)
   67         stop
   68         ;;
   69     reload)
   70         reload
   71         ;;
   72     restart)
   73         stop
   74         start
   75         ;;
   76     try-restart)
   77         if [ -f $pidfile ]; then
   78             stop
   79             start
   80         fi
   81         ;;
   82     force-reload)
   83         reload || (stop; start)
   84         ;;
   85     status)
   86         status $prog
   87         RETVAL=$?
   88         ;;
   89     *)
   90         echo $"Usage: $0 {start|stop|reload|force-reload|restart|try-restart|status}"
   91         RETVAL=3
   92 esac
   93 
   94 exit $RETVAL