From 4445b0709237ce06f4f70f8ad1509afbbf8377c2 Mon Sep 17 00:00:00 2001 From: Lsmoisu <114275920+Lsmoisu@users.noreply.github.com> Date: Sat, 8 Mar 2025 20:28:25 +0800 Subject: [PATCH] Update install.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加定时任务 自动更新配置文件重启服务 --- install.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/install.sh b/install.sh index 707cf87..d083120 100644 --- a/install.sh +++ b/install.sh @@ -70,6 +70,30 @@ if ! command -v sing-box > /dev/null 2>&1; then exit 1 fi +# 设置自动更新配置文件脚本 +echo "设置自动更新配置文件脚本..." +UP_CONFIG_URL="https://github.com/Lsmoisu/sing-box-shell/raw/refs/heads/main/upconfig.sh" +if ! wget -O /usr/local/bin/upconfig.sh "$UP_CONFIG_URL"; then + echo "错误:下载 upconfig.sh 失败,请检查网络或 URL 是否有效" + exit 1 +fi + +# 设置脚本权限 +chmod +x /usr/local/bin/upconfig.sh + +# 检查脚本是否可执行 +if [ ! -x /usr/local/bin/upconfig.sh ]; then + echo "错误:upconfig.sh 设置执行权限失败" + exit 1 +fi + +# 添加 crontab 任务,每分钟执行一次 +echo "配置 crontab 自动更新任务..." +(crontab -l 2>/dev/null | grep -v "upconfig.sh"; echo "* * * * * /usr/local/bin/upconfig.sh") | crontab - +if [ $? -ne 0 ]; then + echo "警告:crontab 配置失败,请手动检查" +fi + # 获取配置文件 URL DEFAULT_CONFIG_URL="https://sub.hechunyu.com/config-zz-realip-route" echo "请输入 sing-box 配置文件 URL(直接回车使用默认值):"