From e7c51f9a0b64a630a89f0cfbe5123f64652749f6 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Tue, 4 Jun 2024 20:08:18 +0200 Subject: [PATCH] simplify bcachefs raid menu --- usr/lib/archboot/installer/bcachefs.sh | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/usr/lib/archboot/installer/bcachefs.sh b/usr/lib/archboot/installer/bcachefs.sh index 470788880..87668e966 100644 --- a/usr/lib/archboot/installer/bcachefs.sh +++ b/usr/lib/archboot/installer/bcachefs.sh @@ -56,22 +56,27 @@ _bcfs_select_raid_devices () { while [[ "${_BCFS_RAID_DEV}" != "> DONE" ]]; do _BCFS_DONE="" _RAIDNUMBER=$((_RAIDNUMBER + 1)) + # clean loop from used partition and options + _BCFS_RAID_DEVS=${_BCFS_RAID_DEVS//${_BCFS_RAID_DEV} _/} ### RAID5/6 is not ready atm 23052024 # RAID5/6 need ec option! # RAID5 needs 3 devices # RAID6 and RAID10 need 4 devices! - [[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 1))" &&\ - ! "${_BCFS_LEVEL}" == "raid10" && ! "${_BCFS_LEVEL}" == "raid6" &&\ - ! "${_BCFS_LEVEL}" == "raid5" ]] && _BCFS_DONE="DONE _" - [[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 2))" &&\ - "${_BCFS_LEVEL}" == "raid5" ]] && _BCFS_DONE="DONE _" - [[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 3))" &&\ - "${_BCFS_LEVEL}" == "raid10" || "${_BCFS_LEVEL}" == "raid6" ]] && _BCFS_DONE="DONE _" - # clean loop from used partition and options - _BCFS_RAID_DEVS=${_BCFS_RAID_DEVS//${_BCFS_RAID_DEV} _/} - # add more devices - #shellcheck disable=SC2086 - _dialog --title " Device ${_RAIDNUMBER} " --no-cancel --menu "" 12 50 6 ${_BCFS_RAID_DEVS} ${_BCFS_DONE} 2>"${_ANSWER}" || return 1 + if [[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 1))" &&\ + ! "${_BCFS_LEVEL}" == "raid10" && ! "${_BCFS_LEVEL}" == "raid6" &&\ + ! "${_BCFS_LEVEL}" == "raid5" ]] ||\ + [[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 2))" &&\ + "${_BCFS_LEVEL}" == "raid5" ]] ||\ + [[ "$((_RAIDNUMBER + _DUR_COUNT))" -ge "$((_BCFS_REP_COUNT + 3))" &&\ + "${_BCFS_LEVEL}" == "raid10" || "${_BCFS_LEVEL}" == "raid6" ]]; then + # add more devices + #shellcheck disable=SC2086 + _dialog --title " Device ${_RAIDNUMBER} " --no-cancel --menu "" 12 50 6 \ + ${_BCFS_RAID_DEVS} "> DONE" "Proceed To Summary" 2>"${_ANSWER}" || return 1 + else + _dialog --title " Device ${_RAIDNUMBER} " --no-cancel --menu "" 12 50 6 \ + ${_BCFS_RAID_DEVS} 2>"${_ANSWER}" || return 1 + fi _BCFS_RAID_DEV=$(cat "${_ANSWER}") [[ "${_BCFS_RAID_DEV}" == "> DONE" ]] && break _bcfs_raid_options || return 1 @@ -117,12 +122,14 @@ _bcfs_raid_level() { _bcfs_select_raid_devices || return 1 # final step ask if everything is ok? #shellcheck disable=SC2028,SC2027,SC2086 - _dialog --title " Summary " --yesno \ + if _dialog --title " Summary " --yesno \ "LEVEL:\n${_BCFS_LEVEL}\nDEVICES:\n$(while read -r i; do echo ""${i}"\n"; done