From 99de5d84b2295a21386abab6a467e63ab9e257f7 Mon Sep 17 00:00:00 2001 From: Ing Date: Wed, 6 Nov 2024 20:35:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20boot.sh=20=E5=92=8C=20menu?= =?UTF-8?q?.sh=EF=BC=8C=E6=B7=BB=E5=8A=A0=20bootwait=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/initrd/opt/rr/boot.sh | 43 +++++++++++++++++++++---------------- files/initrd/opt/rr/menu.sh | 22 +++++++++---------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/files/initrd/opt/rr/boot.sh b/files/initrd/opt/rr/boot.sh index 44516a36..ee44bc74 100755 --- a/files/initrd/opt/rr/boot.sh +++ b/files/initrd/opt/rr/boot.sh @@ -212,6 +212,28 @@ done CMDLINE_LINE=$(echo "${CMDLINE_LINE}" | sed 's/^ //') # Remove leading space echo -e "$(TEXT "Cmdline:\n")\033[1;36m${CMDLINE_LINE}\033[0m" +function _bootwait() { + BOOTWAIT="$(readConfigKey "bootwait" "${USER_CONFIG_FILE}")" + [ -z "${BOOTWAIT}" ] && BOOTWAIT=10 + busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WB + MSG="" + while test ${BOOTWAIT} -ge 0; do + MSG="$(printf "\033[1;33m$(TEXT "%2ds (Changing access(ssh/web) status will interrupt boot)")\033[0m" "${BOOTWAIT}")" + echo -en "\r${MSG}" + busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WC + if ! diff WB WC >/dev/null 2>&1; then + echo -en "\r\033[1;33m$(TEXT "access(ssh/web) status has changed and booting is interrupted.")\033[0m\n" + rm -f WB WC + return 1 + fi + sleep 1 + BOOTWAIT=$((BOOTWAIT - 1)) + done + rm -f WB WC + echo -en "\r$(printf "%$((${#MSG} * 2))s" " ")\n" + return 0 +} + DIRECT="$(readConfigKey "directboot" "${USER_CONFIG_FILE}")" if [ "${DIRECT}" = "true" ]; then grub-editenv ${USER_GRUBENVFILE} set rr_version="$([ -z "${RR_RELEASE}" ] && echo "${RR_TITLE}" || echo "${RR_TITLE}(${RR_RELEASE})")" @@ -227,6 +249,7 @@ if [ "${DIRECT}" = "true" ]; then grub-editenv ${USER_GRUBENVFILE} set dsm_cmdline="${CMDLINE_DIRECT}" grub-editenv ${USER_GRUBENVFILE} set next_entry="direct" + _bootwait || exit 0 echo -e "\033[1;33m$(TEXT "Reboot to boot directly in DSM")\033[0m" reboot exit 0 @@ -297,25 +320,9 @@ else sleep 1 done done - BOOTWAIT="$(readConfigKey "bootwait" "${USER_CONFIG_FILE}")" - [ -z "${BOOTWAIT}" ] && BOOTWAIT=10 - busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WB - MSG="" - while test ${BOOTWAIT} -ge 0; do - MSG="$(printf "\033[1;33m$(TEXT "%2ds (Changing access(ssh/web) status will interrupt boot)")\033[0m" "${BOOTWAIT}")" - echo -en "\r${MSG}" - busybox w 2>/dev/null | awk '{print $1" "$2" "$4" "$5" "$6}' >WC - if ! diff WB WC >/dev/null 2>&1; then - echo -en "\r\033[1;33m$(TEXT "access(ssh/web) status has changed and booting is interrupted.")\033[0m\n" - rm -f WB WC - exit 0 - fi - sleep 1 - BOOTWAIT=$((BOOTWAIT - 1)) - done - rm -f WB WC - echo -en "\r$(printf "%$((${#MSG} * 2))s" " ")\n" + _bootwait || exit 0 + echo -e "\033[1;37m$(TEXT "Loading DSM kernel ...")\033[0m" DSMLOGO="$(readConfigKey "dsmlogo" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/rr/menu.sh b/files/initrd/opt/rr/menu.sh index ef73295d..c13357a5 100755 --- a/files/initrd/opt/rr/menu.sh +++ b/files/initrd/opt/rr/menu.sh @@ -2748,9 +2748,9 @@ function advancedMenu() { if [ -n "${PLATFORM}" ] && [ "true" = "$(readConfigKey "platforms.${PLATFORM}.dt" "${WORK_PATH}/platforms.yml")" ]; then echo "d \"$(TEXT "Custom DTS")\"" >>"${TMP_PATH}/menu" fi + echo "w \"$(TEXT "Timeout of boot wait:") \Z4${BOOTWAIT}\Zn\"" >>"${TMP_PATH}/menu" if [ "${DIRECTBOOT}" = "false" ]; then echo "i \"$(TEXT "Timeout of get ip in boot:") \Z4${BOOTIPWAIT}\Zn\"" >>"${TMP_PATH}/menu" - echo "w \"$(TEXT "Timeout of boot wait:") \Z4${BOOTWAIT}\Zn\"" >>"${TMP_PATH}/menu" echo "k \"$(TEXT "kernel switching method:") \Z4${KERNELWAY}\Zn\"" >>"${TMP_PATH}/menu" fi echo "n \"$(TEXT "Reboot on kernel panic:") \Z4${KERNELPANIC}\Zn\"" >>"${TMP_PATH}/menu" @@ -2831,29 +2831,29 @@ function advancedMenu() { customDTS NEXT="e" ;; - i) + w) ITEMS="$(echo -e "1 \n5 \n10 \n30 \n60 \n")" DIALOG --title "$(TEXT "Advanced")" \ - --default-item "${BOOTIPWAIT}" --no-items --menu "$(TEXT "Choose a time(seconds)")" 0 0 0 ${ITEMS} \ + --default-item "${BOOTWAIT}" --no-items --menu "$(TEXT "Choose a time(seconds)")" 0 0 0 ${ITEMS} \ 2>${TMP_PATH}/resp [ $? -ne 0 ] && continue resp=$(cat ${TMP_PATH}/resp 2>/dev/null) [ -z "${resp}" ] && continue - BOOTIPWAIT=${resp} - writeConfigKey "bootipwait" "${BOOTIPWAIT}" "${USER_CONFIG_FILE}" - NEXT="i" + BOOTWAIT=${resp} + writeConfigKey "bootwait" "${BOOTWAIT}" "${USER_CONFIG_FILE}" + NEXT="w" ;; - w) + i) ITEMS="$(echo -e "1 \n5 \n10 \n30 \n60 \n")" DIALOG --title "$(TEXT "Advanced")" \ - --default-item "${BOOTWAIT}" --no-items --menu "$(TEXT "Choose a time(seconds)")" 0 0 0 ${ITEMS} \ + --default-item "${BOOTIPWAIT}" --no-items --menu "$(TEXT "Choose a time(seconds)")" 0 0 0 ${ITEMS} \ 2>${TMP_PATH}/resp [ $? -ne 0 ] && continue resp=$(cat ${TMP_PATH}/resp 2>/dev/null) [ -z "${resp}" ] && continue - BOOTWAIT=${resp} - writeConfigKey "bootwait" "${BOOTWAIT}" "${USER_CONFIG_FILE}" - NEXT="w" + BOOTIPWAIT=${resp} + writeConfigKey "bootipwait" "${BOOTIPWAIT}" "${USER_CONFIG_FILE}" + NEXT="i" ;; k) [ "${KERNELWAY}" = "kexec" ] && KERNELWAY='power' || KERNELWAY='kexec'