You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB
Bash

#!/bin/sh
. /lib/functions.sh
. /usr/lib/configsync_lib.sh
CS_SERVICE=csstation_quota
SERVICE=station_quota
my_logger() {
logger -t configsync_executor "${CS_SERVICE}" "${@}"
}
system_to_configsync()
{
my_logger "This is ${0} system_to_configsync()!"
config_load ${SERVICE}
copy_cs_global() {
config_get VALUE $1 logging
uci_cs set ${CS_SERVICE}.global.logging="${VALUE}"
config_get VALUE $1 enabled
uci_cs set ${CS_SERVICE}.global.enabled="${VALUE}"
}
config_foreach copy_cs_global global
delete_sections_cs ${CS_SERVICE} entry
copy_cs_entry() {
local entry=$(uci_cs add ${CS_SERVICE} entry)
local option synced_options='station daysofweek quota'
for option in $synced_options; do
config_get VALUE $1 $option
uci_cs set ${CS_SERVICE}.$entry.$option="${VALUE}"
done
}
config_foreach copy_cs_entry entry
uci_cs commit ${CS_SERVICE}
return 0
}
init()
{
my_logger "This is ${0} init()!"
if [ ! -d ${CS_CONFIGURATION_PATH} ]; then
mkdir -p ${CS_CONFIGURATION_PATH}
fi
# clear the current CS config to avoid accidental merging
>${CS_CONFIGURATION_PATH}/${CS_SERVICE}
uci_cs set ${CS_SERVICE}.configsync=info
uci_cs set ${CS_SERVICE}.configsync.version=1
uci_cs set ${CS_SERVICE}.global=global
system_to_configsync init
}
if [ "${1}" = "init" ] || [ "${1}" = "system_to_configsync" ]; then
"${@}"
else
my_logger "Unknown command ${1} in ${0}!"
fi