iopsys-feed/uspd/files/uspd.init
2021-05-12 23:40:37 +05:30

63 lines
1 KiB
Bash

#!/bin/sh /etc/rc.common
START=98
STOP=10
USE_PROCD=1
PROG=/usr/sbin/uspd
validate_uspd_usp_section()
{
uci_validate_section uspd uspd "usp" \
'enabled:bool:true' \
'granularitylevel:uinteger' \
'debug:bool:false' \
'loglevel:uinteger' \
'sock:string' \
'transaction_timeout:string'
}
configure_uspd()
{
local enabled debug sock transaction_timeout
config_load uspd
validate_uspd_usp_section || {
log "Validation of usp section failed"
return 1;
}
[ ${enabled} -eq 0 ] && return 0
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
if [ -n "${transaction_timeout}" ]; then
procd_append_param command -t ${transaction_timeout}
fi
}
start_service() {
procd_open_instance usp
procd_set_param command ${PROG}
configure_uspd
procd_set_param respawn
procd_close_instance
}
reload_service() {
stop
start
}
service_triggers()
{
procd_add_config_trigger "config.change" "uspd" /etc/init.d/uspd restart
}