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.
61 lines
1.4 KiB
Plaintext
61 lines
1.4 KiB
Plaintext
4 years ago
|
#!/bin/sh
|
||
|
|
||
|
. /lib/functions.sh
|
||
|
. /usr/lib/configsync_lib.sh
|
||
|
|
||
|
CS_SERVICE=csparental_control
|
||
|
SERVICE=parental_control
|
||
|
PSERVICE=${CS_PREFIX}${SERVICE}
|
||
|
|
||
|
my_logger() {
|
||
|
logger -t configsync_executor "${CS_SERVICE}" "${@}"
|
||
|
}
|
||
|
|
||
|
configsync_to_system()
|
||
|
{
|
||
|
# make working copy and get values from there step by step
|
||
|
uci_cs export $CS_SERVICE | uci_tmp import $CS_SERVICE
|
||
|
|
||
|
my_logger "This is ${0} configsync_to_system()!"
|
||
|
|
||
|
VALUE=$(uci_tmp get ${CS_SERVICE}.global.logging)
|
||
|
uci_tmp set ${PSERVICE}.@global[0].logging="${VALUE}"
|
||
|
|
||
|
VALUE=$(uci_tmp get ${CS_SERVICE}.global.enabled)
|
||
|
uci_tmp set ${PSERVICE}.@global[0].enabled="${VALUE}"
|
||
|
|
||
|
delete_sections_tmp ${PSERVICE} entry
|
||
|
|
||
|
local option synced_options='stations daysofweek starttime stoptime enabled'
|
||
|
local I=0
|
||
|
while uci_tmp get ${CS_SERVICE}.@entry[${I}] > /dev/null 2>&1; do
|
||
|
local entry=$(uci_tmp add ${PSERVICE} entry)
|
||
|
|
||
|
for option in $synced_options; do
|
||
|
VALUE=$(uci_tmp get ${CS_SERVICE}.@entry[${I}].$option)
|
||
|
uci_tmp set ${PSERVICE}.$entry.$option="${VALUE}"
|
||
|
done
|
||
|
|
||
|
let I=I+1
|
||
|
done
|
||
|
|
||
|
add_to_list $CS_IMPORTSERVICELIST ${SERVICE}
|
||
|
}
|
||
|
|
||
|
dynamic_update()
|
||
|
{
|
||
|
my_logger "This is ${0} dynamic_update()!"
|
||
|
}
|
||
|
|
||
|
init()
|
||
|
{
|
||
|
my_logger "This is ${0} init()!"
|
||
|
}
|
||
|
|
||
|
if [ "${1}" = "init" ] || [ "${1}" = "configsync_to_system" ] || [ "${1}" = "dynamic_update" ]; then
|
||
|
"${@}"
|
||
|
else
|
||
|
my_logger "Unknown command ${1} in ${0}!"
|
||
|
fi
|
||
|
|