~新增openrc启动模式兼容

This commit is contained in:
juewuy
2025-12-07 22:18:47 +08:00
parent 95eba035cf
commit 60b7dd5c21
4 changed files with 113 additions and 57 deletions

View File

@@ -63,6 +63,8 @@ ckstatus() {
[ -n "$(find /etc/rc.d -name '*shellcrash')" ] && autostart=enable || autostart=disable
elif ckcmd systemctl; then
[ "$(systemctl is-enabled shellcrash.service 2>&1)" = enabled ] && autostart=enable || autostart=disable
elif rc-status -r >/dev/null 2>&1; then
rc-update show default | grep -q "shellcrash" && autostart=enable || autostart=disable
else
[ -f ${CRASHDIR}/.dis_startup ] && autostart=disable || autostart=enable
fi
@@ -1169,7 +1171,7 @@ setboot() { #启动相关设置
echo -----------------------------------------------
echo -e "\033[30;47m欢迎使用启动设置菜单\033[0m"
echo -----------------------------------------------
echo -e " 1 ${auto_set}\033[0mShellCrash开机启动(alpine需先禁用再启用)"
echo -e " 1 ${auto_set}\033[0mShellCrash开机启动"
echo -e " 2 使用保守模式: \033[36m$start_old\033[0m ————基于定时任务(每分钟检测)"
echo -e " 3 设置自启延时: \033[36m$delay\033[0m ————用于解决自启后服务受限"
echo -e " 4 启用小闪存模式: \033[36m$mini_clash\033[0m ————用于闪存空间不足的设备"
@@ -1186,8 +1188,7 @@ setboot() { #启动相关设置
# 禁止自启动:删除各系统的启动项
[ -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
[rc-status -r >/dev/null 2>&1 && rc-update del shellcrash default >/dev/null
touch ${CRASHDIR}/.dis_startup
autostart=disable
echo -e "\033[33m已禁止ShellCrash开机启动\033[0m"
@@ -1195,15 +1196,7 @@ setboot() { #启动相关设置
# 允许自启动:配置各系统的启动项
[ -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
rc-status -r >/dev/null 2>&1 && rc-update add shellcrash default >/dev/null
rm -rf ${CRASHDIR}/.dis_startup
autostart=enable
echo -e "\033[32m已设置ShellCrash开机启动\033[0m"
@@ -1219,7 +1212,7 @@ setboot() { #启动相关设置
setconfig start_old $start_old
${CRASHDIR}/start.sh stop
else
if [ "$(cat /proc/1/comm)" = "procd" -o "$(cat /proc/1/comm)" = "systemd" ]; then
if grep -qE 'procd|systemd' /proc/1/comm || rc-status -r >/dev/null 2>&1; then
echo -e "\033[32m改为使用系统守护进程启动服务\033[0m"
${CRASHDIR}/start.sh cronset "ShellCrash初始化"
start_old=未开启
@@ -2060,7 +2053,7 @@ tools() {
[ -f /etc/firewall.user ] && echo -e " 4 \033[32m配置\033[0m外网访问SSH"
[ -x /usr/sbin/otapredownload ] && echo -e " 5 \033[33m$mi_update\033[0m小米系统自动更新"
[ "$systype" = "mi_snapshot" ] && echo -e " 6 小米设备软固化SSH ———— \033[$mi_autoSSH_type \033[0m"
[ -d /etc/ddns ] && echo -e " 7 配置\033[32mDDNS服务\033[0m(需下载相关脚本)"
[ -f /etc/config/ddns ] && echo -e " 7 配置\033[32mDDNS服务\033[0m(需下载相关脚本)"
[ "$systype" = "mi_snapshot" ] && echo -e " 8 小米设备Tun模块修复 ———— \033[$mi_tunfix \033[0m"
echo -----------------------------------------------
echo -e " 0 返回上级菜单"
@@ -2093,12 +2086,12 @@ tools() {
${CRASHDIR}/start.sh get_bin ${TMPDIR}/ShellDDNS.sh tools/ShellDDNS.sh
if [ "$?" = "0" ]; then
mv -f ${TMPDIR}/ShellDDNS.sh ${CRASHDIR}/tools/ShellDDNS.sh
source ${CRASHDIR}/tools/ShellDDNS.sh
. ${CRASHDIR}/tools/ShellDDNS.sh
else
echo -e "\033[31m文件下载失败\033[0m"
fi
else
source ${CRASHDIR}/tools/ShellDDNS.sh
. ${CRASHDIR}/tools/ShellDDNS.sh
fi
sleep 1
tools