研究了下 其实挺简单

dsm7的群晖 启动项管理 变成了 systemd

路径在 /usr/lib/systemd/system/

那么就简单了

ssh登陆群晖 然后切换成root

sudo -s

cd  /volume1/@apphome

mkdir NezhaAgent

# 这里得注意 下载你群晖对应架构的agent
#wget https://github.com/naiba/nezha/releases/download/v0.12.3/nezha-agent_linux_amd64.tar.gz

#ps 20241002修正 现在仓库变了
wget https://github.com/nezhahq/agent/releases/download/v0.19.8/nezha-agent_linux_amd64.zip

#tar -zxvf nezha-agent_linux_amd64.tar.gz
#ps 20241002修正 现在是zip了 但是dms默认没有unzip命令 那么就用7z解压就可以了
7z x nezha-agent_linux_amd64.zip

chmod +x nezha-agent

下面就设置systemd脚本

vim /usr/lib/systemd/system/nezha-agent.service
#下面是systemd脚本

[Unit]
Description=Nezha Agent
After=syslog.target
#After=network.target
#After=nezha-dashboard.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=root
Group=root
WorkingDirectory=/volume1/@apphome/NezhaAgent
ExecStart=/volume1/@apphome/NezhaAgent/nezha-agent --report-delay 3 --disable-command-execute --skip-conn --skip-procs -s 你自己的服务器:443 -p 你自己的密钥 --tls
Restart=always
#Environment=DEBUG=true

# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
#ProtectSystem=full
#PrivateDevices=yes
#PrivateTmp=yes
#NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
//然后启用就行了

systemctl daemon-reload
systemctl enable nezha-agent
systemctl start nezha-agent

// 看下状态

systemctl status nezha-agent