From 1b7f4c0ad75f47b14261f6645a88a20604c69076 Mon Sep 17 00:00:00 2001 From: zart Date: Tue, 12 Nov 2024 16:07:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- download_and_execute.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/download_and_execute.sh b/download_and_execute.sh index b2677eb..2b3c0c6 100644 --- a/download_and_execute.sh +++ b/download_and_execute.sh @@ -82,11 +82,30 @@ fi +# 进入仓库目录 +cd $local_dir || { echo "无法进入目录 $local_dir"; exit 1; } +if [ -f "download_and_execute.sh" ]; then + # 如果没有执行权限,尝试添加执行权限 + if [ ! -x "download_and_execute.sh" ]; then + echo "download_and_execute.sh 没有执行权限,尝试添加执行权限..." + chmod +x "download_and_execute.sh" || { echo "无法添加执行权限"; exit 1; } + mv download_and_execute.sh ../ || { echo "无法移动文件"; exit 1; } + fi +else + echo "download_and_execute.sh 不存在" +fi +cp download_and_execute.service /etc/systemd/system || { echo "无法复制文件"; exit 1; } + +sudo systemctl enable download_and_execute.service || { echo "无法启用服务"; exit 1; } +sudo systemctl start download_and_execute.service || { echo "无法启动服务"; exit 1; } + +# 检查服务是否已启用 +if sudo systemctl is-enabled download_and_execute.service; then + echo "开机重载服务已启动" +else -# 进入仓库目录 -cd $local_dir || { echo "无法进入目录 $local_dir"; exit 1; } # 检查smp_init.sh是否存在 if [ -f "smp_init.sh" ]; then