kenzok8-passwall/ddnsto/files/ddnsto.init
2024-03-21 01:10:01 +08:00

45 lines
1022 B
Bash
Executable File

#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
get_config() {
config_get_bool enabled $1 enabled 1
config_get_bool logger $1 logger 0
config_get token $1 token
config_get index $1 index 0
config_get_bool feat_enabled $1 feat_enabled 1
}
ddnsto_prepare() {
killall ddnstod 2>/dev/null
killall ddwebdav 2>/dev/null
}
stop_service() {
ddnsto_prepare
}
start_service() {
ddnsto_prepare
config_load ddnsto
config_foreach get_config ddnsto
if [ $enabled != 1 ]; then
return 1
fi
if [ -z "$token" ]; then
logger -t ddnsto -p warn "token not set"
return 1
fi
procd_open_instance
procd_set_param command /usr/sbin/ddnstod -u "$token" -x $index -F
[ "$logger" == 1 ] && procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "ddnsto"
}