net/vnstat: port the init-script to procd
This ports the init-script from the legacy functions to procd. There should be no functional changes with this patch. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
This commit is contained in:
parent
9764354572
commit
e1acbd55b6
1 changed files with 15 additions and 19 deletions
|
@ -3,25 +3,21 @@
|
||||||
|
|
||||||
START=99
|
START=99
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
|
||||||
vnstat_option() {
|
vnstat_option() {
|
||||||
sed -ne "s/^[[:space:]]*$1[[:space:]]*['\"]\([^'\"]*\)['\"].*/\1/p" \
|
sed -ne "s/^[[:space:]]*$1[[:space:]]*['\"]\([^'\"]*\)['\"].*/\1/p" \
|
||||||
/etc/vnstat.conf
|
/etc/vnstat.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start_service() {
|
||||||
local lib="$(vnstat_option DatabaseDir)"
|
local lib="$(vnstat_option DatabaseDir)"
|
||||||
local pid="$(vnstat_option PidFile)"
|
|
||||||
|
|
||||||
[ -n "$lib" ] || {
|
[ -n "$lib" ] || {
|
||||||
echo "Error: No DatabaseDir set in vnstat.conf" >&2
|
echo "Error: No DatabaseDir set in vnstat.conf" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -n "$pid" ] || {
|
|
||||||
echo "Error: No PidFile set in vnstat.conf" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdir -p "$lib"
|
mkdir -p "$lib"
|
||||||
|
|
||||||
init_ifaces() {
|
init_ifaces() {
|
||||||
|
@ -72,18 +68,18 @@ start() {
|
||||||
config_load vnstat
|
config_load vnstat
|
||||||
config_foreach init_ifaces vnstat
|
config_foreach init_ifaces vnstat
|
||||||
|
|
||||||
SERVICE_PID_FILE="${pid}"
|
procd_open_instance
|
||||||
service_start /usr/sbin/vnstatd -d
|
procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_set_param command /usr/sbin/vnstatd --nodaemon
|
||||||
|
procd_set_param file /etc/vnstat.conf
|
||||||
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
reload_service() {
|
||||||
local pid="$(vnstat_option PidFile)"
|
procd_send_signal vnstat
|
||||||
|
}
|
||||||
[ -n "$pid" ] || {
|
|
||||||
echo "Error: No PidFile set in vnstat.conf" >&2
|
service_triggers() {
|
||||||
exit 1
|
procd_add_reload_trigger vnstat
|
||||||
}
|
|
||||||
|
|
||||||
SERVICE_PID_FILE="${pid}"
|
|
||||||
service_stop /usr/sbin/vnstatd
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue