Files
sing-box-extended-mirror/release/config/sing-box.initd
T

45 lines
811 B
Plaintext
Raw Normal View History

2024-09-23 22:12:19 +08:00
#!/sbin/openrc-run
name=$RC_SVCNAME
description="sing-box service"
supervisor="supervise-daemon"
command="/usr/bin/sing-box"
2026-03-11 16:32:50 +08:00
extra_commands="checkconfig"
2024-09-23 22:12:19 +08:00
extra_started_commands="reload"
2026-03-11 16:32:50 +08:00
: ${SINGBOX_CONFIG:=${config:-"/etc/sing-box"}}
if [ -d "$SINGBOX_CONFIG" ]; then
_config_opt="-C $SINGBOX_CONFIG"
elif [ -z "$SINGBOX_CONFIG" ]; then
_config_opt=""
else
_config_opt="-c $SINGBOX_CONFIG"
fi
_workdir=${SINGBOX_WORKDIR:-${workdir:-"/var/lib/sing-box"}}
command_args="run --disable-color
-D $_workdir
$_config_opt"
2024-09-23 22:12:19 +08:00
depend() {
after net dns
}
2026-03-11 16:32:50 +08:00
checkconfig() {
ebegin "Checking $RC_SVCNAME configuration"
sing-box check -D "$_workdir" $_config_opt
eend $?
}
start_pre() {
checkconfig
}
2024-09-23 22:12:19 +08:00
reload() {
ebegin "Reloading $RC_SVCNAME"
2026-03-11 16:32:50 +08:00
checkconfig && $supervisor "$RC_SVCNAME" --signal HUP
2024-09-23 22:12:19 +08:00
eend $?
2026-03-11 16:32:50 +08:00
}