mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-25 00:51:21 +00:00
net/vnstat: Update rc script to correctly import old data into new database format
This commit is contained in:
parent
36acdd9f3a
commit
eab817386b
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=485599
@ -3,7 +3,7 @@
|
||||
|
||||
PORTNAME= vnstat
|
||||
PORTVERSION= 2.0
|
||||
PORTREVISION= 0
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net
|
||||
MASTER_SITES= https://humdi.net/vnstat/ \
|
||||
https://source.ipfire.org/source-2.x/
|
||||
|
@ -9,7 +9,6 @@
|
||||
# Add the following line to /etc/rc.conf to enable vnstat:
|
||||
#
|
||||
# vnstat_enable="YES"
|
||||
# vnstat_additional_ifaces="em1"
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
@ -20,7 +19,7 @@ load_rc_config $name
|
||||
: ${vnstat_enable:=NO}
|
||||
: ${vnstat_pidfile=/var/run/vnstat/vnstat.pid}
|
||||
: ${vnstat_config=%%PREFIX%%/etc/vnstat.conf}
|
||||
: ${vnstat_flags="-d --noadd"}
|
||||
: ${vnstat_flags="-d"}
|
||||
: ${vnstat_user:=%%USERS%%}
|
||||
: ${vnstat_group:=%%GROUPS%%}
|
||||
|
||||
@ -31,19 +30,8 @@ user_cmd="%%PREFIX%%/bin/vnstat"
|
||||
|
||||
start_precmd=vnstat_startprecmd
|
||||
|
||||
create_iface_database()
|
||||
{
|
||||
local iface="$1"
|
||||
local descr="$2"
|
||||
su -m ${vnstat_user} -c "${user_cmd} --add --iface $iface" >/dev/null 2>&1 ||
|
||||
! echo "$name: Failed to add database for the $descr interface $iface" || return 1
|
||||
echo "$name: Created the database for the $descr interface $iface"
|
||||
}
|
||||
|
||||
vnstat_startprecmd()
|
||||
{
|
||||
local dbdir iface
|
||||
|
||||
if [ ! -e ${pidfile%/*} ]; then
|
||||
install -d -o ${vnstat_user} -g ${vnstat_group} ${pidfile%/*};
|
||||
fi
|
||||
@ -53,18 +41,6 @@ vnstat_startprecmd()
|
||||
install -d -o ${vnstat_user} -g ${vnstat_group} ${dbdir};
|
||||
fi
|
||||
|
||||
iface=$(grep "^Interface" ${vnstat_config} | head -1 | awk 'BEGIN{FS="\042"}{print $2}')
|
||||
if [ -n "${iface}" -a ! -f ${dbdir}/${iface} ]; then
|
||||
create_iface_database $iface "default" || return 1
|
||||
fi
|
||||
if [ -n "${vnstat_additional_ifaces}" ]; then
|
||||
for iface in ${vnstat_additional_ifaces}; do
|
||||
if [ ! -f ${dbdir}/${iface} ]; then
|
||||
create_iface_database $iface "additional" || return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ! -d "/var/run/vnstat" ]; then
|
||||
install -d -o ${vnstat_user} -g ${vnstat_group} /var/run/vnstat;
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user