-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfix1805.sh
50 lines (50 loc) · 1.39 KB
/
fix1805.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
echo "提示: 此脚本将升级/降级本机nezha-agent至v0.18.5版本(最后一个Websocket-WebShell版本,适配dashboard≤v0.18.2),并禁用自动升级功能。"
read -p "是否继续? (y/n): " choice
case "$choice" in
y|Y )
echo "继续执行脚本..."
;;
n|N )
echo "脚本已退出。"
exit 0
;;
* )
echo "无效输入,脚本已退出。"
exit 1
;;
esac
cd ~
ARCH=$(uname -m)
case "$ARCH" in
x86_64)
ARCH="amd64"
;;
aarch64)
ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
wget https://github.com/nezhahq/agent/releases/download/v0.18.5/nezha-agent_linux_$ARCH.zip -O nezha-agent.zip
unzip nezha-agent.zip
if command -v systemctl > /dev/null 2>&1; then
systemctl stop nezha-agent
cp nezha-agent /opt/nezha/agent
sudo sed -i '/ExecStart=/ s/$/ --disable-auto-update/' /etc/systemd/system/nezha-agent.service
systemctl daemon-reload
systemctl restart nezha-agent
elif command -v rc-service > /dev/null 2>&1; then
rc-service nezha-agent stop
cp nezha-agent /opt/nezha/agent
sudo sed -i 's#command_args="\(.*\)"#command_args="\1 --disable-auto-update"#' /etc/init.d/nezha-agent
rc-update add nezha-agent
rc-service nezha-agent start
else
echo "Unsupported system"
exit 1
fi
rm nezha-agent.zip
rm nezha-agent