mirror of
https://git.myvelabs.com/lab/archlinux.git
synced 2026-10-16 09:24:03 +00:00
More fixes to mirrorsetup
This commit is contained in:
parent
59015d9d01
commit
a4e86694f2
1 changed files with 23 additions and 23 deletions
30
homelab.sh
30
homelab.sh
|
|
@ -545,27 +545,27 @@ function mirrorsetup
|
|||
local found=false
|
||||
for available in "${available_drives[@]}"
|
||||
do
|
||||
if [[ "$drive" == "$available" ]]
|
||||
if [[ "${drive}" == "${available}" ]]
|
||||
then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$found" == false ]]
|
||||
if [[ "${found}" == false ]]
|
||||
then
|
||||
say as warning "Invalid drive selected: $drive"
|
||||
say as warning "Invalid drive selected: ${drive}"
|
||||
valid=false
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Only continue with other validations if drives are valid
|
||||
if [[ "$valid" == true ]]
|
||||
if [[ "${valid}" == true ]]
|
||||
then
|
||||
# Check for duplicates
|
||||
local unique_count=$(printf '%s\n' "${pairArray[@]}" | sort | uniq | wc -l)
|
||||
local total_count=${#pairArray[@]}
|
||||
if [[ $unique_count -lt $total_count ]]
|
||||
if [[ ${unique_count} -lt ${total_count} ]]
|
||||
then
|
||||
say as warning "Duplicate entries detected"
|
||||
valid=false
|
||||
|
|
@ -576,22 +576,22 @@ function mirrorsetup
|
|||
then
|
||||
say as warning 'Mirrored pairs must have at least two drives'
|
||||
valid=false
|
||||
fi
|
||||
|
||||
# Check for stray drives (only after we know drives are valid)
|
||||
else
|
||||
# Only check for stray drives if we have a valid pool (at least 2 drives)
|
||||
local remaining_after=$(( ${#available_drives[@]} - ${#pairArray[@]} ))
|
||||
if [[ $remaining_after -eq 1 ]] && [[ ${#available_drives[@]} -gt ${#pairArray[@]} ]]
|
||||
if [[ ${remaining_after} -eq 1 ]] && [[ ${#available_drives[@]} -gt ${#pairArray[@]} ]]
|
||||
then
|
||||
say as warning 'Remaining drive does not have a mirror pair'
|
||||
valid=false
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Process valid pool
|
||||
if [[ "$valid" == true ]]
|
||||
if [[ "${valid}" == true ]]
|
||||
then
|
||||
# Store this mirror pool configuration
|
||||
pools[$pool_count]="${pairArray[*]}"
|
||||
pools[${pool_count}]="${pairArray[*]}"
|
||||
((pool_count++))
|
||||
|
||||
# Remove selected drives from available list
|
||||
|
|
@ -601,15 +601,15 @@ function mirrorsetup
|
|||
local is_selected=false
|
||||
for selected in "${pairArray[@]}"
|
||||
do
|
||||
if [[ "$drive" == "$selected" ]]
|
||||
if [[ "${drive}" == "${selected}" ]]
|
||||
then
|
||||
is_selected=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$is_selected" == false ]]
|
||||
if [[ "${is_selected}" == false ]]
|
||||
then
|
||||
new_available+=("$drive")
|
||||
new_available+=("${drive}")
|
||||
fi
|
||||
done
|
||||
available_drives=("${new_available[@]}")
|
||||
|
|
@ -623,7 +623,7 @@ function mirrorsetup
|
|||
unset zrootlayout
|
||||
for ((i=0; i<pool_count; i++))
|
||||
do
|
||||
local drives="${pools[$i]}"
|
||||
local drives="${pools[${i}]}"
|
||||
say as success "zroot mirror $((i+1)): ${drives}"
|
||||
zrootlayout+=("mirror ${drives}")
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in a new issue