Files
dock/03
2026-01-25 01:11:31 +08:00

80 lines
2.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 1. 基础环境修复
echo "正在修复基础环境..."
apt-get update
# 修正了之前的 -p 错误参数
apt-get install -y curl wget lsof psmisc
# 2. 准备目录
DATA_DIR="/vol1/1000/dock/rustdesk/data"
mkdir -p "$DATA_DIR"
# 3. 下载安装包 (增加 502 检测和备份源)
echo "正在获取安装包..."
# 尝试使用你的链接,如果失败则尝试官方源
URL_HBBS="https://cloudreve.vps3344521.xyz/f/W9tx/rustdesk-server-hbbs_1.1.15_amd64.deb"
URL_HBBR="https://cloudreve.vps3344521.xyz/f/j3fJ/rustdesk-server-hbbr_1.1.15_amd64.deb"
wget -O hbbs.deb "$URL_HBBS" || wget -O hbbs.deb "https://github.com/rustdesk/rustdesk-server/releases/download/1.1.11-1/rustdesk-server-hbbs_1.1.11_amd64.deb"
wget -O hbbr.deb "$URL_HBBR" || wget -O hbbr.deb "https://github.com/rustdesk/rustdesk-server/releases/download/1.1.11-1/rustdesk-server-hbbr_1.1.11_amd64.deb"
# 检查文件大小,防止下载的是 502 错误页面
if [ ! -s hbbs.deb ]; then
echo "错误:未能下载有效的安装包,请检查网络或 Cloudreve 状态。"
exit 1
fi
# 4. 安装
echo "正在安装软件包..."
dpkg -i hbbs.deb hbbr.deb
apt-get install -f -y
# 5. 配置 Systemd 服务 (确保路径指向你的数据目录)
HOST_IP=$(curl -s4 ifconfig.me)
cat > /etc/systemd/system/rustdesk-hbbs.service <<EOF
[Unit]
Description=RustDesk ID Server
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/hbbs -r ${HOST_IP}:21117 -k _
WorkingDirectory=${DATA_DIR}
Restart=always
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/systemd/system/rustdesk-hbbr.service <<EOF
[Unit]
Description=RustDesk Relay Server
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/hbbr -k _
WorkingDirectory=${DATA_DIR}
Restart=always
[Install]
WantedBy=multi-user.target
EOF
# 6. 启动并显示 Key
systemctl daemon-reload
systemctl enable --now rustdesk-hbbs rustdesk-hbbr
echo "------------------------------------------------"
echo "服务已重启!"
echo "正在等待 Key 文件生成..."
sleep 3
if [ -f "${DATA_DIR}/id_ed25519.pub" ]; then
echo "你的 Key 为:"
cat "${DATA_DIR}/id_ed25519.pub"
else
echo "Key 文件尚未生成请检查服务状态systemctl status rustdesk-hbbs"
fi
echo "------------------------------------------------"