From 3cc31793d57ce05421300ce4e8a1a1352291db85 Mon Sep 17 00:00:00 2001 From: Kim Date: Fri, 6 Aug 2021 12:16:36 +0200 Subject: T1153: VyOS 1.2.0RC10, RAID-1, fresh install, unable to save configEquuleus (#159) * add search for same drive size if more than 2 drives are installed * add ability to configure RAID-1 by selecting 2 drives * cleaning up sysconf/filecaps rights * cleaning up sysconf/filecaps rights xtables-monitor --- scripts/install/install-functions | 58 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'scripts/install/install-functions') diff --git a/scripts/install/install-functions b/scripts/install/install-functions index e319b84d..458d2e63 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -177,7 +177,7 @@ select_drive () { drives=$(cat /proc/partitions | \ awk '{ if ($4!="name") { print $4 } }' | \ egrep "c[0-9]d[0-9]$|[hsv]d[a-z]$|nvme[0-9]n[0-9]|mmcblk[0-9]" | \ - egrep -v "^$") + egrep -v "^$" | sort) #this needs more testing to decide if better than above #drives=$(lsblk -dn -o name -I8) @@ -370,3 +370,59 @@ EOF return 1 } +# Find 2 drives of the same size. +get_size_raid () +{ + x=0 + declare -i x + for drive in "${driveName[@]}" + do + drivesize=${driveSize[$x]} + y=0 + declare -i y + for size in ${driveSize[@]} + do + if [ $drivesize -eq $size ] && [ $drive != ${driveName[$y]} ]; then + raiddrives="${driveName[$y]} $drive" + fi + y+=1 + done + x+=1 + done + if [ -n "$raiddrives" ]; then + echo $raiddrives + fi +} + +# Manually select 2 items for use in RAID-1 +get_manual_raid () +{ + PS3="Select the first drive: " + IFS=$'\n' s_driveNameSize=($(sort <<<"${driveNameSize[*]}")) + unset IFS + select drive1 in "${s_driveNameSize[@]}" + do + break + done + + driveNameSize=() + for drive in "${driveName[@]}" + do + if ! echo $drive1 | grep -q $drive; then + driveNameSize+=("$drive $(get_drive_size $drive) MB") + fi + done + + PS3="Select the second drive: " + IFS=$'\n' s_driveNameSize=($(sort <<<"${driveNameSize[*]}")) + unset IFS + select drive2 in "${s_driveNameSize[@]}" + do + break + done + + drive1=`echo $drive1 | awk '{ print $1 }'` + drive2=`echo $drive2 | awk '{ print $1 }'` + + echo $drive1 $drive2 +} -- cgit v1.2.3