Lines 22-36
Link Here
|
22 |
: ${vnstat_flags="-d --noadd"} |
22 |
: ${vnstat_flags="-d --noadd"} |
23 |
: ${vnstat_user:=%%USERS%%} |
23 |
: ${vnstat_user:=%%USERS%%} |
24 |
: ${vnstat_group:=%%GROUPS%%} |
24 |
: ${vnstat_group:=%%GROUPS%%} |
|
|
25 |
: ${vnstat_additional_ifaces:=""} |
25 |
|
26 |
|
26 |
command="%%PREFIX%%/sbin/vnstatd" |
27 |
command="%%PREFIX%%/sbin/vnstatd" |
27 |
command_args="-p ${vnstat_pidfile} --config ${vnstat_config}" |
28 |
command_args="-p ${vnstat_pidfile} --config ${vnstat_config}" |
28 |
pidfile="${vnstat_pidfile}" |
29 |
pidfile="${vnstat_pidfile}" |
|
|
30 |
user_cmd="%%PREFIX%%/bin/vnstat" |
29 |
|
31 |
|
30 |
start_precmd=vnstat_startprecmd |
32 |
start_precmd=vnstat_startprecmd |
31 |
|
33 |
|
|
|
34 |
create_iface_database() { |
35 |
local iface="$1" |
36 |
local descr="$2" |
37 |
su -m ${vnstat_user} -c "${user_cmd} --create --iface $iface" >/dev/null 2>&1 || |
38 |
! echo "$name: Failed to create database for the $descr interface $iface" || return 1 |
39 |
echo "$name: Created the database for the $descr interface $iface" |
40 |
} |
41 |
|
32 |
vnstat_startprecmd() |
42 |
vnstat_startprecmd() |
33 |
{ |
43 |
{ |
|
|
44 |
local dbdir iface |
45 |
|
34 |
if [ ! -e ${pidfile%/*} ]; then |
46 |
if [ ! -e ${pidfile%/*} ]; then |
35 |
install -d -o ${vnstat_user} -g ${vnstat_group} ${pidfile%/*}; |
47 |
install -d -o ${vnstat_user} -g ${vnstat_group} ${pidfile%/*}; |
36 |
fi |
48 |
fi |
Lines 40-45
Link Here
|
40 |
install -d -o ${vnstat_user} -g ${vnstat_group} ${dbdir}; |
52 |
install -d -o ${vnstat_user} -g ${vnstat_group} ${dbdir}; |
41 |
fi |
53 |
fi |
42 |
|
54 |
|
|
|
55 |
iface=$(grep "^Interface" ${vnstat_config} | head -1 | awk 'BEGIN{FS="\042"}{print $2}') |
56 |
if [ -n "${iface}" -a ! -f ${dbdir}/${iface} ]; then |
57 |
create_iface_database $iface "default" || return 1 |
58 |
fi |
59 |
if [ -n "${vnstat_additional_ifaces}" ]; then |
60 |
for iface in ${vnstat_additional_ifaces}; do |
61 |
if [ ! -f ${dbdir}/${iface} ]; then |
62 |
create_iface_database $iface "additional" || return 1 |
63 |
fi |
64 |
done |
65 |
fi |
66 |
|
43 |
if [ ! -d "/var/run/vnstat" ]; then |
67 |
if [ ! -d "/var/run/vnstat" ]; then |
44 |
install -d -o ${vnstat_user} -g ${vnstat_group} /var/run/vnstat; |
68 |
install -d -o ${vnstat_user} -g ${vnstat_group} /var/run/vnstat; |
45 |
fi |
69 |
fi |