From 5367daabc8b145ec2be0f137a088eb298319b558 Mon Sep 17 00:00:00 2001 From: zart Date: Tue, 12 Nov 2024 16:38:38 +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.service | 2 +- smp_init.sh | 20 ++------------------ 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/download_and_execute.service b/download_and_execute.service index 01b1e99..623a9de 100644 --- a/download_and_execute.service +++ b/download_and_execute.service @@ -3,7 +3,7 @@ Description=Run download_and_execute script at startup After=network.target [Service] -ExecStart=/home/pi/download_and_execute.sh +ExecStart=/home/pi/smp_pc/smp_init.sh Type=oneshot Restart=on-failure RestartSec=10s diff --git a/smp_init.sh b/smp_init.sh index 24c153e..f708844 100644 --- a/smp_init.sh +++ b/smp_init.sh @@ -10,28 +10,12 @@ if sudo systemctl is-enabled download_and_execute.service; then echo "开机重载服务已启动" else echo "开机重载服务未启动" - 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 - + echo "正在启动开机重载服务" sudo 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; } +# sudo systemctl start download_and_execute.service || { echo "无法启动服务"; exit 1; } fi - - - - - #!/bin/bash # 创建一个目录用于存放虚拟环境