From 7eff2e3c1093fa9b2140b969102b4ce87adc65eb Mon Sep 17 00:00:00 2001 From: xzx3344521 Date: Mon, 3 Nov 2025 10:55:27 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E8=AF=95=E9=AA=8C=E7=94=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 试验用脚本 | 197 +++++++++++++++++++++++++++-------------------------- 1 file changed, 99 insertions(+), 98 deletions(-) diff --git a/试验用脚本 b/试验用脚本 index 86aafa5..49480e3 100644 --- a/试验用脚本 +++ b/试验用脚本 @@ -1,102 +1,103 @@ -cat > fix-syncthing-install.sh << 'EOF' -#!/bin/bash +# 完全重新配置 +systemctl stop syncthing +rm -rf /var/lib/syncthing/config/* -echo "========================================" -echo " Syncthing 修复安装脚本" -echo "========================================" +# 重新生成配置并指定监听地址 +sudo -u syncthing /usr/local/bin/syncthing -generate="/var/lib/syncthing/config" -# 修复系统依赖 -echo "安装系统依赖..." -apt update -apt install -y gnupg2 curl wget - -# 清理之前的错误配置 -echo "清理旧配置..." -systemctl stop syncthing 2>/dev/null -systemctl disable syncthing 2>/dev/null -rm -f /etc/systemd/system/syncthing.service -rm -f /etc/apt/sources.list.d/syncthing.list - -# 方法1: 使用通用安装(推荐) -echo "使用通用安装方法..." -cd /tmp -LATEST_VERSION=$(curl -s https://api.github.com/repos/syncthing/syncthing/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') -ARCH=$(uname -m) - -case $ARCH in - x86_64) ARCH="amd64" ;; - aarch64) ARCH="arm64" ;; - armv7l) ARCH="armv7" ;; - *) ARCH="amd64" ;; -esac - -echo "下载 Syncthing $LATEST_VERSION ($ARCH)" -wget -q https://github.com/syncthing/syncthing/releases/download/${LATEST_VERSION}/syncthing-linux-${ARCH}-${LATEST_VERSION}.tar.gz -tar -xzf syncthing-linux-${ARCH}-${LATEST_VERSION}.tar.gz -cp syncthing-linux-${ARCH}-${LATEST_VERSION}/syncthing /usr/local/bin/ -chmod +x /usr/local/bin/syncthing - -# 创建配置目录 -echo "创建配置目录..." -useradd -r -s /bin/false -d /var/lib/syncthing -m syncthing 2>/dev/null || true -mkdir -p /var/lib/syncthing/config -chown -R syncthing:syncthing /var/lib/syncthing - -# 创建正确的服务文件 -echo "创建系统服务..." -cat > /etc/systemd/system/syncthing.service << 'SERVICE' -[Unit] -Description=Syncthing -Documentation=man:syncthing(1) -After=network.target - -[Service] -User=syncthing -ExecStart=/usr/local/bin/syncthing serve --no-browser --no-restart --home=/var/lib/syncthing/config -Restart=on-failure -RestartSec=5 -SuccessExitStatus=3 4 -RestartForceExitStatus=3 4 - -[Install] -WantedBy=multi-user.target -SERVICE - -# 启动服务 -echo "启动服务..." -systemctl daemon-reload -systemctl enable syncthing -systemctl start syncthing - -sleep 3 - -if systemctl is-active --quiet syncthing; then - echo "✓ Syncthing 服务启动成功" -else - echo "查看服务状态..." - systemctl status syncthing -l --no-pager - echo "尝试手动启动..." - sudo -u syncthing /usr/local/bin/syncthing -generate="/var/lib/syncthing/config" - systemctl start syncthing -fi - -# 显示信息 -echo "" -echo "========================================" -echo " Syncthing 安装完成!" -echo "========================================" -IP=$(hostname -I | awk '{print $1}') -echo "访问地址: https://$IP:8384" -echo "" -echo "管理命令:" -echo " systemctl start syncthing" -echo " systemctl stop syncthing" -echo " systemctl restart syncthing" -echo " systemctl status syncthing" -echo "" -echo "查看运行状态:" -systemctl status syncthing --no-pager -l +# 手动修改配置 +cat > /var/lib/syncthing/config/config.xml << 'EOF' + + + basic + + 1 + + 0 + 0 + 0 + random + false + 0 + 0 + 0 + false + false + false + 25 + .stfolder + false + false + false + false + false + + false + standard + standard + 0 + + +
dynamic
+
+ +
0.0.0.0:8384
+ $(cat /var/lib/syncthing/config/config.xml | grep apikey | sed -n 's/.*\(.*\)<\/apikey>.*/\1/p') + default +
+ + + default + default + true + true + 0 + 0 + 60 + true + 10 + false + true + 60 + 30 + 10 + 0 + 3 + $(cat /var/lib/syncthing/config/config.xml | grep urUniqueID | sed -n 's/.*\(.*\)<\/urUniqueID>.*/\1/p') + https://data.syncthing.net/ + false + 1800 + true + 12 + false + 24 + false + 5 + false + 1 + https://upgrades.syncthing.net/meta.json + false + 10 + authenticationUserAndPassword + 0 + /var/lib/syncthing/sync + true + 1 + false + 0 + 0 + default + auto + 0 + true + false + + 0 + 0 + false + +
EOF -chmod +x fix-syncthing-install.sh -./fix-syncthing-install.sh +chown -R syncthing:syncthing /var/lib/syncthing/config +systemctl start syncthing