summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--network/vnstat/README25
-rw-r--r--network/vnstat/doinst.sh11
-rw-r--r--network/vnstat/rc.vnstat73
-rw-r--r--network/vnstat/vnstat.SlackBuild19
-rw-r--r--network/vnstat/vnstat.info9
5 files changed, 119 insertions, 18 deletions
diff --git a/network/vnstat/README b/network/vnstat/README
index a22949bbfb..c53c6a459c 100644
--- a/network/vnstat/README
+++ b/network/vnstat/README
@@ -6,5 +6,26 @@ so vnStat can be used without root permissions.
This program is open source (GPL) and can be installed in 'single' and
'root' mode.
-Add the following line to your crontab:
-0-55/5 * * * * if [[ -x /usr/bin/vnstat && $(ls /var/lib/vnstat/ | wc -l) -ge 1 ]]; then /usr/bin/vnstat -u; fi
+Note that you can run vnstat either from cron or as a daemon from /etc/rc.d.
+
+To run vnstat from cron:
+ Add the following line to your crontab:
+ 0-55/5 * * * * if [[ -x /usr/bin/vnstat && $(ls /var/lib/vnstat/ | wc -l) -ge 1 ]]; then /usr/bin/vnstat -u; fi
+
+To run vnstat from /etc/rc.d:
+ chmod +x /etc/rc.d/rc.vnstat
+
+Note that to have vnstat start automatically this way it should be called from
+rc.local (and optionally rc.local_shutdown) like so:
+
+ In rc.local:
+ # Start vnstat
+ if [ -x /etc/rc.d/rc.vnstat ]; then
+ /etc/rc.d/rc.vnstat start
+ fi
+
+ In rc.local_shutdown:
+ # Stop vnstat
+ if [ -x /etc/rc.d/rc.vnstat ]; then
+ /etc/rc.d/rc.vnstat stop
+ fi
diff --git a/network/vnstat/doinst.sh b/network/vnstat/doinst.sh
index 206b717881..052e2f8929 100644
--- a/network/vnstat/doinst.sh
+++ b/network/vnstat/doinst.sh
@@ -1,5 +1,3 @@
-#!/bin/sh
-
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
@@ -13,5 +11,12 @@ config() {
# Otherwise, we leave the .new copy for the admin to consider...
}
-config etc/vnstat.conf.new
+# Keep same perms on rc.vnstat.new:
+if [ -e etc/rc.d/rc.vnstat ]; then
+ cp -a etc/rc.d/rc.vnstat etc/rc.d/rc.vnstat.new.incoming
+ cat etc/rc.d/rc.vnstat.new > etc/rc.d/rc.vnstat.new.incoming
+ mv etc/rc.d/rc.vnstat.new.incoming etc/rc.d/rc.vnstat.new
+fi
+config etc/rc.d/rc.vnstat.new
+config etc/vnstat.conf.new
diff --git a/network/vnstat/rc.vnstat b/network/vnstat/rc.vnstat
new file mode 100644
index 0000000000..bb9e948c02
--- /dev/null
+++ b/network/vnstat/rc.vnstat
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# /etc/rc.d/rc.vnstat - Start/stop/restart the vndstat daemon.
+# To make vnstat start automatically at boot, make this
+# file executable: chmod 0755 /etc/rc.d/rc.vnstat
+#
+
+CONFIGFILE="/etc/vnstat.conf"
+INTERFACE="eth0"
+
+DBASEDIR="/var/lib/vnstat/"
+PIDFILE="/var/run/vnstat.pid"
+
+vnstat_start() {
+ if [ -e "$PIDFILE" ]; then
+ echo "vnstatd is already running under PID: $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
+ 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..."
+ if [ -r $PIDFILE ]; then
+ kill $(cat $PIDFILE)
+ sleep 2
+ if [ -e "$PIDFILE" ]; then
+ rm $PIDFILE
+ fi
+ echo "Done"
+ else
+ killall vnstatd
+ echo "Done"
+ fi
+}
+
+vnstat_restart() {
+ echo "restarting the vnstart daemon..."
+ vnstat_stop
+ sleep 2
+ vnstat_start
+}
+
+
+case "$1" in
+ 'start')
+ vnstat_start
+ ;;
+ 'stop')
+ vnstat_stop
+ ;;
+ 'restart','reload')
+ vnstat_restart
+ ;;
+ 'status')
+ vnstat_status
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload|status}"
+ exit 1
+ ;;
+esac
+
+
diff --git a/network/vnstat/vnstat.SlackBuild b/network/vnstat/vnstat.SlackBuild
index b31203c273..1c3b403d96 100644
--- a/network/vnstat/vnstat.SlackBuild
+++ b/network/vnstat/vnstat.SlackBuild
@@ -23,7 +23,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=vnstat
-VERSION=1.6
+VERSION=${VERSION:-1.7}
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
@@ -33,10 +33,6 @@ TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
-DOCFILES="CHANGES COPYING FAQ INSTALL README UNINSTALL UPGRADE"
-
-set -e
-
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
@@ -50,6 +46,9 @@ find . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
+# Exit on most errors.
+set -e
+
# vnstat doesn't have a proper configure. So we set the locations in the
# Makefiles properly by the way of sed-fu
sed -i 's#MAN = $(DESTDIR)/usr/share/man#MAN = $(DESTDIR)/usr/man#' \
@@ -81,13 +80,15 @@ make install DESTDIR=$PKG
for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done
)
-( cd $PKG/usr/doc/$PRGNAM-$VERSION/scripts/ ; mv $PRGNAM ${PRGNAM}_cron )
-
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/
-cp -a $DOCFILES $PKG/usr/doc/$PRGNAM-$VERSION
-cp -a pppd/* $PKG/usr/doc/$PRGNAM-$VERSION/scripts
+cp -a CHANGES COPYING FAQ INSTALL INSTALL_BSD README UPGRADE UNINSTALL \
+ examples $PKG/usr/doc/$PRGNAM-$VERSION
+cat cron/$PRGNAM > $PKG/usr/doc/$PRGNAM-$VERSION/examples/$PRGNAM.cron
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+mkdir -p $PKG/etc/rc.d
+cat $CWD/rc.$PRGNAM > $PKG/etc/rc.d/rc.$PRGNAM.new
+
mkdir -p $PKG/install
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc
diff --git a/network/vnstat/vnstat.info b/network/vnstat/vnstat.info
index 5063a1c5ed..8a0cac9680 100644
--- a/network/vnstat/vnstat.info
+++ b/network/vnstat/vnstat.info
@@ -1,8 +1,9 @@
PRGNAM="vnstat"
-VERSION="1.6"
+VERSION="1.7"
HOMEPAGE="http://humdi.net/vnstat/"
-DOWNLOAD="http://humdi.net/vnstat/vnstat-1.6.tar.gz"
-MD5SUM="ccaffe8e70d47e0cf2f25e52daa25712"
+DOWNLOAD="http://humdi.net/vnstat/vnstat-1.7.tar.gz"
+MD5SUM="e5788e8122e34f2c93561e2a84c19432"
MAINTAINER="Michiel van Wessem"
EMAIL="michiel@slackbuilds.org"
-APPROVED="rworkman"
+APPROVED="dsomero"
+