From 52139ded22d47a4d8c5940a6c27e1843a1d6735f Mon Sep 17 00:00:00 2001 From: Andrew Klassen Date: Mon, 10 Jun 2019 00:29:14 -0700 Subject: [PATCH] ready for review --- README.md | 3 +- data/translations/danish.trans | 20 +++++ data/translations/dutch.trans | 20 +++++ data/translations/english.trans | 19 +++++ data/translations/french.trans | 20 +++++ data/translations/german.trans | 20 +++++ data/translations/hungarian.trans | 20 +++++ data/translations/italian.trans | 20 +++++ data/translations/polish.trans | 20 +++++ data/translations/portuguese.trans | 20 +++++ data/translations/portuguese_brasil.trans | 20 +++++ data/translations/russian.trans | 20 +++++ data/translations/spanish.trans | 20 +++++ data/translations/turkish.trans | 19 +++++ data/translations/ukrainian.trans | 20 +++++ lib/util-base.sh | 94 +++++++++++++++++++++ lib/util-desktop.sh | 61 ++++++++++++++ lib/util-disk.sh | 99 +++++++++++++++++++++++ lib/util-menu.sh | 37 +++++---- 19 files changed, 554 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7778ba3..726eead 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ CLI net-installer for Manjarolinux, forked from Carl Duff's Architect This installer provides netinstallation for different manjaro editions. It sources the iso-profiles git repo, so it should be always up to date. -**menu overview of v0.9.9:** +**menu overview of v0.9.10:** ``` Main Menu @@ -12,6 +12,7 @@ Main Menu | ├── Set Virtual Console | ├── List Devices | ├── Partition Disk +| ├── RAID | ├── LUKS Encryption | ├── Logical Volume Management | ├── Mount Partitions diff --git a/data/translations/danish.trans b/data/translations/danish.trans index 59a6525..93a6b45 100644 --- a/data/translations/danish.trans +++ b/data/translations/danish.trans @@ -552,3 +552,23 @@ _DataRecMenu="Data recovery" # translate me ! _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/dutch.trans b/data/translations/dutch.trans index 93c135a..ab86e57 100644 --- a/data/translations/dutch.trans +++ b/data/translations/dutch.trans @@ -549,3 +549,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/english.trans b/data/translations/english.trans index 924b996..1f0d94f 100644 --- a/data/translations/english.trans +++ b/data/translations/english.trans @@ -552,3 +552,22 @@ _DataRecBody="Various tools for data backup and recovery" _HostCache="Choose pacman cache" _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." +#RAID menu +_PrepRAID="RAID (optional)" + +_RAIDLevelTitle="Select a RAID level." +_RAIDLevel0="disk striping" +_RAIDLevel1="mirroring" +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" +_RAIDLevel10="raid 1+0, (requires 4 disks)" + +_PartitionSelectTitle="Partion Select" +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." + +_DeviceNameTitle="Device Name" +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" + +_ArrayCreatedTitle="Array Created" +_ArrayCreatedDescription="The RAID array has been created successfully." diff --git a/data/translations/french.trans b/data/translations/french.trans index 569d70c..f4c03a6 100644 --- a/data/translations/french.trans +++ b/data/translations/french.trans @@ -553,3 +553,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/german.trans b/data/translations/german.trans index dc5ba1b..b804717 100644 --- a/data/translations/german.trans +++ b/data/translations/german.trans @@ -546,3 +546,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/hungarian.trans b/data/translations/hungarian.trans index 94413a0..5960d35 100644 --- a/data/translations/hungarian.trans +++ b/data/translations/hungarian.trans @@ -550,3 +550,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/italian.trans b/data/translations/italian.trans index 6743f69..09a81b3 100644 --- a/data/translations/italian.trans +++ b/data/translations/italian.trans @@ -549,3 +549,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/polish.trans b/data/translations/polish.trans index 447251b..c1c7f9d 100644 --- a/data/translations/polish.trans +++ b/data/translations/polish.trans @@ -549,3 +549,23 @@ _DataRecBody="Różne narzędzia przydatne przy odzyskiwaniu danych i tworzenia _HostCache="Wybierz pacman cache" _HostCacheBody="Czy chcesz użyć pacman cache działającego systemu zamiast zajmować się celem instalacyjnym? Takie działanie może zredukować rozmiar wymaganych pobrań podczas instalacji" + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/portuguese.trans b/data/translations/portuguese.trans index d0d0335..e508d72 100644 --- a/data/translations/portuguese.trans +++ b/data/translations/portuguese.trans @@ -548,3 +548,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/portuguese_brasil.trans b/data/translations/portuguese_brasil.trans index 5ae7956..23e8326 100644 --- a/data/translations/portuguese_brasil.trans +++ b/data/translations/portuguese_brasil.trans @@ -551,3 +551,23 @@ _DataRecBody="Várias ferramentas para backup e recuperação de dados" _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/russian.trans b/data/translations/russian.trans index 746c9be..f092a4f 100644 --- a/data/translations/russian.trans +++ b/data/translations/russian.trans @@ -553,3 +553,23 @@ _DataRecBody="Различные инструменты для резервно _HostCache="Выберите кэш pacman" _HostCacheBody="Хотите ли вы использовать кэш pacman запущенной системы вместо кэша устанавливаемой системы? Это может уменьшить количество необходимых для скачивания файлов." + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/spanish.trans b/data/translations/spanish.trans index 5fb5d0d..a24f388 100644 --- a/data/translations/spanish.trans +++ b/data/translations/spanish.trans @@ -549,3 +549,23 @@ _DataRecBody="Various tools for data backup and recovery" # translate me ! _HostCache="Choose pacman cache" # translate me ! _HostCacheBody="Do you want to use the pacman cache of the running system instead of the installation target? This can reduce the size of the required downloads in the installation." # translate me ! + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/turkish.trans b/data/translations/turkish.trans index 478ad1d..fe8cc87 100755 --- a/data/translations/turkish.trans +++ b/data/translations/turkish.trans @@ -503,3 +503,22 @@ _DataRecBody="Veri yedekleme ve kurtarma için çeşitli araçlar" _HostCache="Pacman önbelleğini seç" _HostCacheBody="Kurulum hedefi yerine çalışan sistemin pacman önbelleğini kullanmak ister misiniz? Bu, kurulumda gerekli indirmelerin boyutunu azaltabilir." +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/data/translations/ukrainian.trans b/data/translations/ukrainian.trans index 3c88b6e..eab0189 100644 --- a/data/translations/ukrainian.trans +++ b/data/translations/ukrainian.trans @@ -550,3 +550,23 @@ _DataRecBody="Різні утиліти для копіювання та від _HostCache="Виберіть кеш pacman " _HostCacheBody="Ви хочете використовувати кеш pacman з працюючої системи, замість кешу системи цільового встановлення? Це може зменшити розмір необхідних завантажень в процесі встановлення." + +#RAID menu +_PrepRAID="RAID (optional)" # translate me ! + +_RAIDLevelTitle="Select a RAID level." # translate me ! +_RAIDLevel0="disk striping" # translate me ! +_RAIDLevel1="mirroring" # translate me ! +_RAIDLevel5="distributed parity, (1 drive tolerance, requires 3 disks)" # translate me ! +_RAIDLevel6="double parity, (2 drive tolerance, requires 4 disks)" # translate me ! +_RAIDLevel10="raid 1+0, (requires 4 disks)" # translate me ! + +_PartitionSelectTitle="Partion Select" # translate me ! +_PartitionSelectDescription="Select the partitions you want to use for this RAID array." # translate me ! + +_DeviceNameTitle="Device Name" # translate me ! +_DeviceNameDescription="What would you like the RAID device to named? \nFor an example, its a standard for the first raid device in system to be named md0. " # translate me ! +_DeviceNamePrefixWarning="(don't prefix with /dev/md/)" # translate me ! + +_ArrayCreatedTitle="Array Created" # translate me ! +_ArrayCreatedDescription="The RAID array has been created successfully." # translate me ! diff --git a/lib/util-base.sh b/lib/util-base.sh index 8de7590..a6d9550 100644 --- a/lib/util-base.sh +++ b/lib/util-base.sh @@ -308,6 +308,67 @@ install_base() { ;; esac + + + # check to see if raid is needed for boot + # if mount point is on raid then it is needed + if [[ $(lsblk -lno TYPE,MOUNTPOINT | grep -E "raid.*${MOUNTPOINT}" | wc -l)> 0 ]]; then + raid_needed=true + + # put all the lines of lsblk, before the mountpoint, into an array + # iterate through the array backwards util a partition is reached + # if raid was involved anywere between the mountpoint and partition, + # then inital ramdisk configuration for raid is need + else + + old_ifs="$IFS" + IFS=$'\n' + lsblk_lines=($(lsblk -lno TYPE,NAME,MOUNTPOINT | sed "/\/${MOUNTPOINT:1}$/q")) + IFS="$old_ifs" + + for (( i=${#lsblk_lines[@]}-1 ; i>=0 ; i-- )) ; do + if [[ $(echo ${lsblk_lines[i]} | grep "^lvm" | wc -l) > 0 ]]; then + sed -i 's/\/& lvm2/' ${MOUNTPOINT}/etc/mkinitcpio.conf + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^crypt" | wc -l) > 0 ]]; then + sed -i 's/\/& encrypt/' ${MOUNTPOINT}/etc/mkinitcpio.conf + sed -i 's/\/& keymap/' ${MOUNTPOINT}/etc/mkinitcpio.conf + sed -i 's/\/& keyboard/' ${MOUNTPOINT}/etc/mkinitcpio.conf + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^raid" | wc -l) > 0 ]]; then + raid_needed=true + raid_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ') + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^part" | wc -l) > 0 ]]; then + break + fi + done + + fi + + + # add mkinitcpio raid binary and hook, if root partition is on raid + if [ "$raid_needed" = true ]; then + + # auto assemble raid + mdadm --detail --scan >> ${MOUNTPOINT}/etc/mdadm.conf + + # add raid initramfs hook + sed -i 's/\/& mdadm_udev/' ${MOUNTPOINT}/etc/mkinitcpio.conf + binaries_line_number=$(grep -n "^BINARIES=(" ${MOUNTPOINT}/etc/mkinitcpio.conf | cut -f1 -d':') + sed -i "${binaries_line_number}s/^\(.\{10\}\)/\1mdmon/" ${MOUNTPOINT}/etc/mkinitcpio.conf + + # get newest kernel and initramfs + newest_kernel=$(ls ${MOUNTPOINT}/lib/modules | grep '^[0-9]' | sort | tail -n 1) + newest_initramfs=$(ls ${MOUNTPOINT}/boot | grep "initramfs" | grep -v "fallback"| sort | tail -n 1) + + # initramfs needs to be recomiled with raid support + manjaro-chroot ${MOUNTPOINT} mkinitcpio -c /etc/mkinitcpio.conf -g /boot/${newest_initramfs} -k ${newest_kernel} + + fi recheck_luks @@ -362,6 +423,39 @@ install_bootloader() { else HIGHLIGHT_SUB=2 fi + + # put all the lines of lsblk, before the mountpoint, into an array + # iterate through the array backwards util a partition is reached + # if luks and raid was involved anywere between the mountpoint and partition, + # then grub configuration for raid and luks is needed + + old_ifs="$IFS" + IFS=$'\n' + lsblk_lines=($(lsblk -lno TYPE,NAME,MOUNTPOINT | sed "/\/${MOUNTPOINT:1}$/q")) + IFS="$old_ifs" + + for (( i=${#lsblk_lines[@]}-1 ; i>=0 ; i-- )) ; do + if [[ $(echo ${lsblk_lines[i]} | grep "^crypt" | wc -l) > 0 ]]; then + luks_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ') + luks_needed=true + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^raid" | wc -l) > 0 ]]; then + raid_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ') + raid_needed=true + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^part" | wc -l) > 0 ]]; then + break + fi + done + + # update grub for luks if needed + if [ "$luks_needed" = true ] && [ "$raid_needed" = true ]; then + sed -i "s/^GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=\/dev\/md\/${raid_device_name}:${luks_device_name}\"/g" ${MOUNTPOINT}/etc/default/grub + manjaro-chroot ${MOUNTPOINT} update-grub + fi + } uefi_bootloader() { diff --git a/lib/util-desktop.sh b/lib/util-desktop.sh index f03eb1c..b6efc1d 100644 --- a/lib/util-desktop.sh +++ b/lib/util-desktop.sh @@ -367,7 +367,68 @@ install_desktop() { ;; esac + + + # check to see if raid is needed for boot + # if mount point is on raid then it is needed + if [[ $(lsblk -lno TYPE,MOUNTPOINT | grep -E "raid.*${MOUNTPOINT}" | wc -l)> 0 ]]; then + raid_needed=true + + # put all the lines of lsblk, before the mountpoint, into an array + # iterate through the array backwards util a partition is reached + # if raid was involved anywere between the mountpoint and partition, + # then inital ramdisk configuration for raid is need + else + + old_ifs="$IFS" + IFS=$'\n' + lsblk_lines=($(lsblk -lno TYPE,NAME,MOUNTPOINT | sed "/\/${MOUNTPOINT:1}$/q")) + IFS="$old_ifs" + + for (( i=${#lsblk_lines[@]}-1 ; i>=0 ; i-- )) ; do + if [[ $(echo ${lsblk_lines[i]} | grep "^lvm" | wc -l) > 0 ]]; then + sed -i 's/\/& lvm2/' ${MOUNTPOINT}/etc/mkinitcpio.conf + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^crypt" | wc -l) > 0 ]]; then + sed -i 's/\/& encrypt/' ${MOUNTPOINT}/etc/mkinitcpio.conf + sed -i 's/\/& keymap/' ${MOUNTPOINT}/etc/mkinitcpio.conf + sed -i 's/\/& keyboard/' ${MOUNTPOINT}/etc/mkinitcpio.conf + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^raid" | wc -l) > 0 ]]; then + raid_needed=true + raid_device_name=$(echo ${lsblk_lines[i]} | cut -f2 -d' ') + continue + fi + if [[ $(echo ${lsblk_lines[i]} | grep "^part" | wc -l) > 0 ]]; then + break + fi + done + + fi + + + # add mkinitcpio raid binary and hook, if root partition is on raid + if [ "$raid_needed" = true ]; then + # auto assemble raid + mdadm --detail --scan >> ${MOUNTPOINT}/etc/mdadm.conf + + # add raid initramfs hook + sed -i 's/\/& mdadm_udev/' ${MOUNTPOINT}/etc/mkinitcpio.conf + binaries_line_number=$(grep -n "^BINARIES=(" ${MOUNTPOINT}/etc/mkinitcpio.conf | cut -f1 -d':') + sed -i "${binaries_line_number}s/^\(.\{10\}\)/\1mdmon/" ${MOUNTPOINT}/etc/mkinitcpio.conf + + # get newest kernel and initramfs + newest_kernel=$(ls ${MOUNTPOINT}/lib/modules | grep '^[0-9]' | sort | tail -n 1) + newest_initramfs=$(ls ${MOUNTPOINT}/boot | grep "initramfs" | grep -v "fallback"| sort | tail -n 1) + + # initramfs needs to be recomiled with raid support + manjaro-chroot ${MOUNTPOINT} mkinitcpio -c /etc/mkinitcpio.conf -g /boot/${newest_initramfs} -k ${newest_kernel} + + fi + recheck_luks # add luks and lvm hooks as needed diff --git a/lib/util-disk.sh b/lib/util-disk.sh index d89f0f9..bd8663b 100644 --- a/lib/util-disk.sh +++ b/lib/util-disk.sh @@ -134,6 +134,18 @@ find_partitions() { partition_list=$(lsblk -lno NAME,SIZE,TYPE | grep $INCLUDE_PART | sed 's/part$/\/dev\//g' | sed 's/lvm$\|crypt$/\/dev\/mapper\//g' | \ awk '{print $3$1 " " $2}' | awk '!/mapper/{a[++i]=$0;next}1;END{while(x/dev/null | awk '{printf "/dev/zvol/%s %s\n", $1, $2}') + # create a raid partition list + old_ifs="$IFS" + IFS=$'\n' + raid_partitions=($(lsblk -lno NAME,SIZE,TYPE | grep raid | awk '{print $1,$2}' | uniq)) + IFS="$old_ifs" + + # add raid partitions to partition_list + for i in "${raid_partitions[@]}" + do + partition_list="${partition_list} /dev/md/${i}" + done + for i in ${partition_list}; do PARTITIONS="${PARTITIONS} ${i}" NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS + 1 )) @@ -494,6 +506,93 @@ make_swap() { ini mount.swap "${PARTITION}" } +raid_level_menu() { + declare -i loopmenu=1 + while ((loopmenu)); do + RAID_OPT="" + DIALOG "RAID" --menu "\n$_RAIDLevelTitle\n" 20 75 6 \ + "0" "$_RAIDLevel0" \ + "1" "$_RAIDLevel1" \ + "5" "$_RAIDLevel5" \ + "6" "$_RAIDLevel6" \ + "10" "$_RAIDLevel10" \ + "$_Back" "-" 2>${ANSWER} + + case $(cat ${ANSWER}) in + "0") raid_array_menu 0 + ;; + "1") raid_array_menu 1 + ;; + "5") raid_array_menu 5 + ;; + "6") raid_array_menu 6 + ;; + "10") raid_array_menu 10 + ;; + *) loopmenu=0 + return 0 + ;; + esac + done +} + +raid_create() { + + RAID_DEVICES=${1} + RAID_DEVICE_NUMBER=$(echo ${1} | wc -w) + RAID_LEVEL=${2} + RAID_DEVICE_NAME=${3} + + # creates the array + mdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES} + + # array is disassembled and reassembled to prevent the array from being named /dev/md/md127 + # the check of /etc/mdadm.conf is preformed to prevent the user from adding duplicate entries + if [[ $(cat /etc/mdadm.conf | grep "/dev/md/${RAID_DEVICE_NAME}" | wc -l) == 0 ]]; then + mdadm --detail --scan | grep -e "/dev/md/${RAID_DEVICE_NAME}" -e "/dev/md/md127" >> /etc/mdadm.conf + mdadm --stop /dev/md/${RAID_DEVICE_NAME} + mdadm --assemble --scan + fi + + DIALOG "$__ArrayCreatedTitle" --msgbox "\n$_ArrayCreatedDescription\n\nmdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES}\n" 0 0 + +} + +raid_get_array_name() { + + DIALOG "$_DeviceNameTitle" --inputbox "\n$_DeviceNameDescription\n\n$_DeviceNamePrefixWarning\n" 0 0 2>${ANSWER} + + raid_device_name=$(cat ${ANSWER}) + + if [[ ${raid_device_name} != "" ]]; then + raid_create "${1}" ${2} ${raid_device_name} + fi + +} + +raid_array_menu() { + + # find raid partitions. + INCLUDE_PART='part\|crypt' + umount_partitions + find_partitions + + # Amend partition(s) found for use in check list + PARTITIONS=$(echo $PARTITIONS | sed 's/M\|G\|T/& off/g') + RAID_LEVEL=${1} + + # select partitions for the array + echo "" > $ANSWER + while [[ $(cat ${ANSWER}) == "" ]]; do + DIALOG "$_PartitionSelectTitle" --checklist "\n$__PartitionSelectDescription\n\n$_UseSpaceBar\n " 0 0 12 ${PARTITIONS} 2> ${ANSWER} + done + + ANSWERS=$(cat ${ANSWER}) + + raid_get_array_name "${ANSWERS[@]}" ${RAID_LEVEL} + +} + luks_menu() { declare -i loopmenu=1 while ((loopmenu)); do diff --git a/lib/util-menu.sh b/lib/util-menu.sh index e4c9563..f901de8 100644 --- a/lib/util-menu.sh +++ b/lib/util-menu.sh @@ -223,20 +223,21 @@ prep_menu() { local PARENT="$FUNCNAME" declare -i loopmenu=1 while ((loopmenu)); do - submenu 13 + submenu 14 DIALOG " $_PrepMenuTitle " --default-item ${HIGHLIGHT_SUB} --menu "\n$_PrepMenuBody\n " 0 0 0 \ "1" "$_VCKeymapTitle" \ "2" "$_DevShowOpt" \ "3" "$_PrepPartDisk|>" \ - "4" "$_PrepLUKS|>" \ - "5" "$_PrepLVM $_PrepLVM2|>" \ - "6" "$_PrepZFS|>" \ - "7" "$_PrepMntPart" \ - "8" "$_PrepMirror|>" \ - "9" "$_PrepPacKey" \ - "10" "$_HostCache" \ - "11" "Enable fsck hook" \ - "12" "$_Back" 2>${ANSWER} + "4" "$_PrepRAID|>" \ + "5" "$_PrepLVM $_PrepLVM2|>" \ + "6" "$_PrepLUKS|>" \ + "7" "$_PrepZFS|>" \ + "8" "$_PrepMntPart" \ + "9" "$_PrepMirror|>" \ + "10" "$_PrepPacKey" \ + "11" "$_HostCache" \ + "12" "Enable fsck hook" \ + "13" "$_Back" 2>${ANSWER} HIGHLIGHT_SUB=$(cat ${ANSWER}) case $(cat ${ANSWER}) in @@ -248,17 +249,19 @@ prep_menu() { "3") umount_partitions select_device && create_partitions ;; - "4") luks_menu + "4") raid_level_menu ;; "5") lvm_menu ;; - "6") zfs_menu + "6") luks_menu ;; - "7") mount_partitions + "7") zfs_menu ;; - "8") configure_mirrorlist + "8") mount_partitions ;; - "9") clear + "9") configure_mirrorlist + ;; + "10") clear ( ctrlc(){ return 0 @@ -269,9 +272,9 @@ prep_menu() { check_for_error 'refresh pacman-keys' ) ;; - "10") set_cache + "11") set_cache ;; - "11") set_fsck_hook + "12") set_fsck_hook ;; *) loopmenu=0 return 0