From 7e54b14a4c26404b64b58788bf8d6784ceb7a9e3 Mon Sep 17 00:00:00 2001 From: ChowRex Date: Mon, 13 Feb 2023 16:18:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96Sync=20English=20version=20intro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the `systemd` script to install agent on DSM7 --- docs/en_US/guide/agent.md | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/docs/en_US/guide/agent.md b/docs/en_US/guide/agent.md index 0009ccb4..833053db 100644 --- a/docs/en_US/guide/agent.md +++ b/docs/en_US/guide/agent.md @@ -137,6 +137,50 @@ EOF ### Installing Agent on Synology DSM - Please refer to the community article: [哪吒探针——群晖客户端(被控端)安装教程](https://wl.gta5pdx.cn/archives/546/)(Chinese) + +- Using Systemd *Only available on DSM7*: + ```sh + # Path of the agent binary file. + EXEC="/PATH/TO/nezha-agent" + # Path of the agent's log. + LOG="${EXEC}.log" + # Extend arguments, can be blank. + ARGS="--disable-command-execute" + # The address of nezha server's GRPC. + SERVER="HOST_OR_IP:GRPC_PORT" + # The token of host. + SECRET="APP_SECRET" + # Specify `run_as` user. * Strongly suggest NOT use `root`! * + RUN_USER="nezha" + # Create the service file. + cat << EOF > /usr/lib/systemd/system/nezha.service + [Unit] + Description=Nezha Agent Service + After=network.target + [Service] + Type=simple + ExecStart=/bin/nohup ${EXEC} ${ARGS} -s ${SERVER} -p ${SECRET} &>> ${LOG} & + ExecStop=ps -fe |grep nezha-agent|awk '{print \$2}'|xargs kill + User=${RUN_USER} + Restart=on-abort + [Install] + WantedBy=multi-user.target + EOF + # Reload services + systemctl daemon-reload + # Start the agent service + systemctl start nezha + # Enable auto-start + systemctl enable nezha + ``` + ‼️DO IT WHEN YOU HAVE MODIFIED THE ENVS‼️ + + ‼️DO IT WHEN YOU HAVE MODIFIED THE ENVS‼️ + + ‼️DO IT WHEN YOU HAVE MODIFIED THE ENVS‼️ + + Using `root` to execute command above, that's all. +
### Installing Agent on MacOS