mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-14 21:10:11 +01:00
80 lines
1.7 KiB
Bash
80 lines
1.7 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
|
|
START=65
|
|
STOP=10
|
|
|
|
USE_PROCD=1
|
|
PROG=/usr/sbin/bbfdmd
|
|
|
|
BBFDM_JSON_INPUT="/etc/bbfdm/input.json"
|
|
BBFDM_TEMP_JSON="/tmp/bbfdm.json"
|
|
|
|
log() {
|
|
echo "${@}"|logger -t bbfdmd.init -p info
|
|
}
|
|
|
|
validate_bbfdm_bbfdmd_section()
|
|
{
|
|
uci_validate_section bbfdm bbfdmd "bbfdmd" \
|
|
'enabled:bool:true' \
|
|
'debug:bool:false' \
|
|
'loglevel:uinteger' \
|
|
'sock:string' \
|
|
'refresh_time:uinteger' \
|
|
'transaction_timeout:uinteger' \
|
|
'subprocess_level:uinteger'
|
|
}
|
|
|
|
configure_bbfdmd()
|
|
{
|
|
local enabled debug sock
|
|
|
|
config_load bbfdm
|
|
|
|
validate_bbfdm_bbfdmd_section || {
|
|
log "Validation of bbfdmd section failed"
|
|
return 1;
|
|
}
|
|
|
|
[ "${enabled}" -eq 0 ] && return 0
|
|
|
|
[ ! -f "${BBFDM_JSON_INPUT}" ] && return 0
|
|
|
|
if [ -n "${loglevel}" ]; then
|
|
echo "$(jq --arg res ${loglevel} '.daemon.config += {"loglevel": $res}' ${BBFDM_JSON_INPUT})" > ${BBFDM_TEMP_JSON}
|
|
cp ${BBFDM_TEMP_JSON} ${BBFDM_JSON_INPUT}
|
|
fi
|
|
|
|
if [ -n "${refresh_time}" ]; then
|
|
echo "$(jq --arg res ${refresh_time} '.daemon.config += {"refresh_time": $res}' ${BBFDM_JSON_INPUT})" > ${BBFDM_TEMP_JSON}
|
|
cp ${BBFDM_TEMP_JSON} ${BBFDM_JSON_INPUT}
|
|
fi
|
|
|
|
if [ -n "${transaction_timeout}" ]; then
|
|
echo "$(jq --arg res ${transaction_timeout} '.daemon.config += {"transaction_timeout": $res}' ${BBFDM_JSON_INPUT})" > ${BBFDM_TEMP_JSON}
|
|
cp ${BBFDM_TEMP_JSON} ${BBFDM_JSON_INPUT}
|
|
fi
|
|
|
|
procd_set_param command ${PROG}
|
|
if [ "${debug}" -eq 1 ]; then
|
|
procd_set_param stdout 1
|
|
procd_set_param stderr 1
|
|
fi
|
|
|
|
if [ -f "${sock}" ]; then
|
|
procd_append_param command -s "${sock}"
|
|
fi
|
|
}
|
|
|
|
start_service()
|
|
{
|
|
procd_open_instance "bbfdm"
|
|
configure_bbfdmd
|
|
procd_set_param respawn
|
|
procd_close_instance "bbfdm"
|
|
}
|
|
|
|
service_triggers()
|
|
{
|
|
procd_add_reload_trigger "bbfdm"
|
|
}
|