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.

59 lines
1.2 KiB
Bash

#!/bin/sh
. /lib/functions.sh
. /usr/lib/configsync_lib.sh
CS_SERVICE=cssystem
SERVICE=system
my_logger() {
logger -t configsync_executor "${CS_SERVICE}" "${@}"
}
system_to_configsync()
{
my_logger "This is ${0} system_to_configsync()!"
config_load ${SERVICE}
config_get VALUE ntp enabled
uci_cs set ${CS_SERVICE}.ntp.enabled="${VALUE}"
config_get VALUE ntp enable_server
uci_cs set ${CS_SERVICE}.ntp.enable_server="${VALUE}"
addlist()
{
uci_cs add_list ${CS_SERVICE}.ntp.server="${1}"
}
uci_cs delete ${CS_SERVICE}.ntp.server
config_list_foreach ntp server addlist
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}.ntp=timeserver
system_to_configsync init
}
if [ "${1}" = "init" ] || [ "${1}" = "system_to_configsync" ]; then
"${@}"
else
my_logger "Unknown command ${1} in ${0}!"
fi