packages/utils/sysstat/files/sysstat.init
Jeffery To 1b48b88c95 sysstat: Update init script
This replaces the use of uci_validate_section() with
uci_load_validate(), which removes the need to declare local variables
for every config option.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
2019-02-12 14:57:40 +08:00

50 lines
1.1 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=90
STOP=10
USE_PROCD=1
PROG=/usr/lib/sysstat/sadc
SYSSTAT_CFG="/etc/sysstat/sysstat"
validate_sysstat_section() {
uci_load_validate sysstat sysstat "$1" "$2" \
'log_history:uinteger' \
'compressafter:uinteger' \
'sadc_options:string' \
'sa_dir:string' \
'zip:string' \
'enabled:string'
}
start_sysstat_instance() {
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
[ -d /var/log/sysstat ] || mkdir -p /var/log/sysstat
echo "HISTORY=$log_history" > $SYSSTAT_CFG
echo "COMPRESSAFTER=$compressafter" >> $SYSSTAT_CFG
echo "SADC_OPTIONS=\"$sadc_options\"" >> $SYSSTAT_CFG
echo "SA_DIR=\"$sa_dir\"" >> $SYSSTAT_CFG
echo "ZIP=\"$zip\"" >> $SYSSTAT_CFG
echo "ENABLED=\"$enabled\"" >> $SYSSTAT_CFG
procd_open_instance
procd_set_param command $PROG -S DISK -F -L -
procd_set_param file $SYSSTAT_CFG
procd_close_instance
}
start_service() {
validate_sysstat_section sysstat start_sysstat_instance
}
service_triggers()
{
procd_add_reload_trigger "sysstat"
procd_add_validation validate_sysstat_section
}