mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-10 23:41:22 +00:00
refactor: replace recursion with while loop in setboot
This commit is contained in:
@@ -11,6 +11,7 @@ allow_autostart(){
|
||||
rc-status -r >/dev/null 2>&1 && rc-update add shellcrash default >/dev/null 2>&1
|
||||
rm -rf "$CRASHDIR"/.dis_startup
|
||||
}
|
||||
|
||||
disable_autostart() {
|
||||
[ -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
|
||||
@@ -19,7 +20,9 @@ disable_autostart(){
|
||||
touch "$CRASHDIR"/.dis_startup
|
||||
}
|
||||
|
||||
setboot() { #启动设置菜单
|
||||
# 启动设置菜单
|
||||
setboot() {
|
||||
while true; do
|
||||
[ -z "$start_old" ] && start_old=OFF
|
||||
[ -z "$start_delay" -o "$start_delay" = 0 ] && delay=未设置 || delay="${start_delay}秒"
|
||||
check_autostart && auto_set="\033[33m禁止" || auto_set="\033[32m允许"
|
||||
@@ -39,7 +42,9 @@ setboot() { #启动设置菜单
|
||||
read -p "请输入对应数字 > " num
|
||||
echo "-----------------------------------------------"
|
||||
case "$num" in
|
||||
0) ;;
|
||||
"" | 0)
|
||||
break
|
||||
;;
|
||||
1)
|
||||
if check_autostart; then
|
||||
# 禁止自启动:删除各系统的启动项
|
||||
@@ -50,7 +55,6 @@ setboot() { #启动设置菜单
|
||||
allow_autostart
|
||||
echo -e "\033[32m已设置ShellCrash开机启动!\033[0m"
|
||||
fi
|
||||
setboot
|
||||
;;
|
||||
2)
|
||||
if [ "$start_old" = "OFF" ] >/dev/null 2>&1; then
|
||||
@@ -72,7 +76,6 @@ setboot() { #启动设置菜单
|
||||
fi
|
||||
fi
|
||||
sleep 1
|
||||
setboot
|
||||
;;
|
||||
3)
|
||||
echo -e "\033[33m如果你的设备启动后可以正常使用,则无需设置!!\033[0m"
|
||||
@@ -89,7 +92,6 @@ setboot() { #启动设置菜单
|
||||
;;
|
||||
esac
|
||||
sleep 1
|
||||
setboot
|
||||
;;
|
||||
4)
|
||||
dir_size=$(df "$CRASHDIR" | awk '{ for(i=1;i<=NF;i++){ if(NR==1){ arr[i]=$i; }else{ arr[i]=arr[i]" "$i; } } } END{ for(i=1;i<=NF;i++){ print arr[i]; } }' | grep Ava | awk '{print $2}')
|
||||
@@ -116,7 +118,6 @@ setboot() { #启动设置菜单
|
||||
fi
|
||||
setconfig BINDIR "$BINDIR" "$CRASHDIR"/configs/command.env
|
||||
sleep 1
|
||||
setboot
|
||||
;;
|
||||
5)
|
||||
echo -e "\033[33m如设置到内存,则每次开机后都自动重新下载相关文件\033[0m"
|
||||
@@ -157,7 +158,6 @@ setboot() { #启动设置菜单
|
||||
;;
|
||||
esac
|
||||
setconfig BINDIR "$BINDIR" "$CRASHDIR"/configs/command.env
|
||||
setboot
|
||||
;;
|
||||
6)
|
||||
echo -e "\033[33m如果你的设备启动后可以正常使用,则无需变更设置!!\033[0m"
|
||||
@@ -173,11 +173,12 @@ setboot() { #启动设置菜单
|
||||
setconfig network_check "$network_check"
|
||||
}
|
||||
sleep 1
|
||||
setboot
|
||||
;;
|
||||
*)
|
||||
errornum
|
||||
sleep 1
|
||||
break
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user