改进脚本

main
zart 3 months ago
parent 6ec8f0b06e
commit 5367daabc8

@ -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

@ -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
# 创建一个目录用于存放虚拟环境

Loading…
Cancel
Save