aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfeld <feld@FreeBSD.org>2013-07-12 19:27:12 +0800
committerfeld <feld@FreeBSD.org>2013-07-12 19:27:12 +0800
commit7ba6cf2f966dc21ea60d96afa179425c288ecb80 (patch)
tree9ac37f4c35b148c9195aad34fcd0113315dd9ae9
parentcbe2b5d079972c1370a998e571e948df62fe942b (diff)
downloadfreebsd-ports-gnome-7ba6cf2f966dc21ea60d96afa179425c288ecb80.tar.gz
freebsd-ports-gnome-7ba6cf2f966dc21ea60d96afa179425c288ecb80.tar.zst
freebsd-ports-gnome-7ba6cf2f966dc21ea60d96afa179425c288ecb80.zip
- rc script improvements
Approved by: swills (mentor)
-rw-r--r--net/vnstat/Makefile2
-rw-r--r--net/vnstat/files/vnstat.in26
2 files changed, 18 insertions, 10 deletions
diff --git a/net/vnstat/Makefile b/net/vnstat/Makefile
index 775d090d6e89..6a3fdc8e9b6a 100644
--- a/net/vnstat/Makefile
+++ b/net/vnstat/Makefile
@@ -3,7 +3,7 @@
PORTNAME= vnstat
PORTVERSION= 1.11
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= net
MASTER_SITES= http://humdi.net/vnstat/ \
http://mirror.mcx2.org/
diff --git a/net/vnstat/files/vnstat.in b/net/vnstat/files/vnstat.in
index 53dcc9d964f5..3593a06e7610 100644
--- a/net/vnstat/files/vnstat.in
+++ b/net/vnstat/files/vnstat.in
@@ -9,8 +9,6 @@
# Add the following line to /etc/rc.conf to enable vnstat:
#
# vnstat_enable="YES"
-# vnstat_flags="-d -p ${vnstat_pidfile} --config %%PREFIX%%/etc/vnstat.cfg"
-# vnstat_pidfile="/var/run/vnstat/vnstat.pid"
. /etc/rc.subr
@@ -18,14 +16,15 @@ name=vnstat
rcvar=vnstat_enable
load_rc_config $name
-vnstat_enable=${vnstat_enable-"NO"}
-vnstat_pidfile=${vnstat_pidfile-"/var/run/vnstat/vnstat.pid"}
-vnstat_flags=${vnstat_flags-"-d -p ${vnstat_pidfile} --config %%PREFIX%%/etc/vnstat.cfg"}
-vnstat_user=${vnstat_user-"%%USERS%%"}
-vnstat_group=${vnstat_group-"%%GROUPS%%"}
+: ${vnstat_enable:=NO}
+: ${vnstat_pidfile:=/var/run/vnstat/vnstat.pid}
+: ${vnstat_config:=%%PREFIX%%/etc/vnstat.conf}
+: ${vnstat_flags:="-d --noadd"}
+: ${vnstat_user:=%%USERS%%}
+: ${vnstat_group:=%%GROUPS%%}
command="%%PREFIX%%/sbin/vnstatd"
-command_args="${vnstat_flags}"
+command_args="-p ${vnstat_pidfile} --config ${vnstat_config}"
pidfile="${vnstat_pidfile}"
start_precmd=vnstat_startprecmd
@@ -33,7 +32,16 @@ start_precmd=vnstat_startprecmd
vnstat_startprecmd()
{
if [ ! -e ${pidfile%/*} ]; then
- install -d -o ${vnstat_user} -g ${vnstat_group} ${pidfile%/*}
+ install -d -o ${vnstat_user} -g ${vnstat_group} ${pidfile%/*};
+ fi
+
+ dbdir=$(grep "^DatabaseDir" ${vnstat_config} | awk 'BEGIN{FS="\042"}{print $2}')
+ if [ ! -d ${dbdir} ]; then
+ install -d -o ${vnstat_user} -g ${vnstat_group} ${dbdir};
+ fi
+
+ if [ ! -d "/var/run/vnstat" ]; then
+ install -d -o ${vnstat_user} -g ${vnstat_group} /var/run/vnstat;
fi
}