#!/sbin/openrc-run

description="NexusGate node agent"
command="/opt/nexusgate-agent/nexusgate-agent"
command_background="yes"
pidfile="/run/nexusgate-agent.pid"
output_log="/var/log/nexusgate/agent.log"
error_log="/var/log/nexusgate/agent-error.log"

# Go 二进制直接从环境变量读取 NG_CONTROLLER/NG_AGENT_KEY；OpenRC 不读
# /etc/nexusgate/agent.env，这里在服务脚本里手动 source 并导出。
if [ -f /etc/nexusgate/agent.env ]; then
  set -a
  . /etc/nexusgate/agent.env
  set +a
fi

depend() {
  need net
  use nexusgate-sing-box
}

start_pre() {
  checkpath --directory --mode 0750 /var/log/nexusgate
}
