diff options
author | Mario Preksavec <mario@slackware.hr> | 2015-04-22 06:47:44 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2015-04-22 06:47:44 +0700 |
commit | 83edde123b9985c05c488101d6a762293789886f (patch) | |
tree | c8dda72083ae77c4b7cf28de2115d9782cdae001 /network/vnstat/rc.vnstat | |
parent | 5423f793daa7eac7152a0f32670d99d598cf5db3 (diff) |
network/vnstat: Updated for version 1.13.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network/vnstat/rc.vnstat')
-rw-r--r-- | network/vnstat/rc.vnstat | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/network/vnstat/rc.vnstat b/network/vnstat/rc.vnstat index e17d7cdeebe7..77cde83d87de 100644 --- a/network/vnstat/rc.vnstat +++ b/network/vnstat/rc.vnstat @@ -5,48 +5,39 @@ # file executable: chmod 0755 /etc/rc.d/rc.vnstat # -CONFIGFILE="/etc/vnstat.conf" -INTERFACE="eth0" +# Modified by Mario Preksavec <mario@slackware.hr> -DBASEDIR="/var/lib/vnstat/" -PIDFILE="/var/run/vnstat.pid" +CONFIGFILE=/etc/vnstat.conf +PIDFILE=/var/run/vnstat.pid +DAEMON=vnstatd vnstat_start() { - if [ -e "$PIDFILE" ]; then - echo "vnstatd is already running under PID: $PIDFILE" + if [ -e $PIDFILE -a -n "$(pidof $DAEMON)" ]; then + echo "vnstatd is already running with pid $(cat $PIDFILE)" elif [ -x /usr/sbin/vnstatd -a -r $CONFIGFILE ]; then - if [ ! -e "$DBASEDIR/$INTERFACE" ]; then - # Sadly vnstat throws everything out over STDOUT instead of - # using STERR for warnings and such. - /usr/bin/vnstat -u -i "$INTERFACE" 1> /dev/null - sleep 2 - fi - echo "Starting the vnstat daemon for interface $INTERFACE..." - /usr/sbin/vnstatd --config $CONFIGFILE --daemon + echo "Starting the vnstat daemon..." + /usr/sbin/vnstatd --config $CONFIGFILE --daemon fi } vnstat_stop() { - # There be demons here. I am sure we can get the pid from /var/run/ - # for a much cleaner shutdown. - echo -n "Stopping the vnstat Daemon..." + echo -n "Stopping the vnstat daemon..." if [ -r $PIDFILE ]; then kill $(cat $PIDFILE) - sleep 2 - if [ -e "$PIDFILE" ]; then - rm $PIDFILE - fi - echo "Done" + sleep 2 + if [ -e "$PIDFILE" ]; then + rm $PIDFILE + fi + echo "Done" else - killall vnstatd - echo "Done" + killall $DAEMON + echo "Done" fi } vnstat_status() { - pid="$(pidof $1)" - if [ -n "$pid" ]; then - echo "vnstat daemon is running with pid $pid" + if [ -e $PIDFILE -a -n "$(pidof $DAEMON)" ]; then + echo "vnstat daemon is running with pid $(cat $PIDFILE)" else echo "vnstat daemon is not running." fi @@ -67,13 +58,13 @@ case "$1" in vnstat_stop ;; 'restart'|'reload') - vnstat_restart - ;; + vnstat_restart + ;; 'status') - vnstat_status vnstatd - ;; + vnstat_status + ;; *) - echo "Usage: $0 {start|stop|restart|reload|status}" - exit 1 - ;; + echo "Usage: $0 {start|stop|restart|reload|status}" + exit 1 + ;; esac |