From 6b83aae199099885488c897e69c59c9f5a537f0c Mon Sep 17 00:00:00 2001 From: wwd Date: Fri, 28 Nov 2025 18:06:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0alpine=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/init.sh | 18 ++++++++++++++++++ scripts/menu.sh | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/scripts/init.sh b/scripts/init.sh index 68c94a0..a56eec8 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -202,6 +202,24 @@ else setconfig start_old 已开启 fi fi + +# 在此处添加Alpine OpenRC配置(约第220-230行附近) +# Alpine Linux (OpenRC) 自启动配置 +if [ -f "/sbin/openrc" ] && [ "$(cat /proc/1/comm)" = "init" ]; then + # 创建启动脚本 + if [ ! -f "/etc/local.d/shellcrash.start" ]; then + echo "#!/bin/sh" > /etc/local.d/shellcrash.start + echo "${CRASHDIR}/start.sh start &" >> /etc/local.d/shellcrash.start + chmod +x /etc/local.d/shellcrash.start + fi + # 添加到默认运行级别 + rc-update add local default >/dev/null 2>&1 + setconfig autostart "enable" + logger "已配置Alpine系统自启动" 32 +fi + + + #修饰文件及版本号 command -v bash >/dev/null 2>&1 && shtype=bash [ -x /bin/ash ] && shtype=ash diff --git a/scripts/menu.sh b/scripts/menu.sh index 13fc2b0..01b01c5 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -1127,14 +1127,27 @@ setboot() { #启动相关设置 0) ;; 1) if [ "$autostart" = "enable" ]; then + # 禁止自启动:删除各系统的启动项 [ -d /etc/rc.d ] && cd /etc/rc.d && rm -rf *shellcrash >/dev/null 2>&1 && cd - >/dev/null ckcmd systemctl && systemctl disable shellcrash.service >/dev/null 2>&1 + # 新增:删除Alpine的启动脚本 + [ -f "/sbin/openrc" ] && rm -f /etc/local.d/shellcrash.start touch ${CRASHDIR}/.dis_startup autostart=disable echo -e "\033[33m已禁止ShellCrash开机启动!\033[0m" elif [ "$autostart" = "disable" ]; then + # 允许自启动:配置各系统的启动项 [ -f /etc/rc.common -a "$(cat /proc/1/comm)" = "procd" ] && /etc/init.d/shellcrash enable ckcmd systemctl && systemctl enable shellcrash.service >/dev/null 2>&1 + # 新增:配置Alpine的启动脚本 + if [ -f "/sbin/openrc" ]; then + [ ! -f "/etc/local.d/shellcrash.start" ] && { + echo "#!/bin/sh" > /etc/local.d/shellcrash.start + echo "${CRASHDIR}/start.sh start &" >> /etc/local.d/shellcrash.start + chmod +x /etc/local.d/shellcrash.start + } + rc-update add local default >/dev/null 2>&1 + fi rm -rf ${CRASHDIR}/.dis_startup autostart=enable echo -e "\033[32m已设置ShellCrash开机启动!\033[0m"