#!/bin/sh # # vnstatd console-based network traffic monitor # # chkconfig: 345 90 10 # description: vnStat is a console-based network traffic monitor # that keeps a log of daily network traffic for the # selected interface(s). # processname: vnstatd # config: /etc/vnstatd.conf # pidfile: /var/run/vnstatd/vnstatd.pid # ### BEGIN INIT INFO # Provides: vnstatd # Required-Start: $network # Required-Stop: $network # Should-Start: $time $syslog # Should-Stop: $syslog # Default-Start: 345 # Default-Stop: 0 1 2 6 # Short-Description: This shell script starts and stops vnstatd daemon # Description: vnStat is a console-based network traffic monitor # that keeps a log of daily network traffic for the # selected interface(s). ### END INIT INFO # Do not load RH compatibility interface. WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions PIDDIR=/var/run/vnstatd/ PIDFILE=$PIDDIR/vnstatd.pid LOCKFILE=/var/lock/subsys/vnstatd VN_USER=vnstat RETVAL=0 start() { [ -d "$PIDDIR" ] || mkdir -p "$PIDDIR" chmod 1775 "$PIDDIR" chown root:"$VN_USER" "$PIDDIR" start_daemon --lockfile "$LOCKFILE" --set-user "$VN_USER" -- vnstatd -d --pidfile "$PIDFILE" RETVAL=$? return $RETVAL } stop() { stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user "$VN_USER" -- vnstatd RETVAL=$? return $RETVAL } restart() { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) restart; ;; restart) restart ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; condreload) if [ -e "$LOCKFILE" ]; then restart fi ;; status) status --pidfile "$PIDFILE" --expect-user "$VN_USER" -- vnstatd RETVAL=$? ;; *) msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}" RETVAL=1 esac exit $RETVAL