1-get-initial-setup-working #2
29
setup.sh
29
setup.sh
@ -105,6 +105,35 @@ function zpool_drive_id () {
|
||||
exit 1
|
||||
}
|
||||
|
||||
function select_part () {
|
||||
local parts enriched_parts enriched_parts_count part_number part_type
|
||||
declare part
|
||||
part_type="${1:?}" # 'efi' or 'zfs'
|
||||
parts="$(get_parts "${part_type}")"
|
||||
|
||||
if we_have_exactly_one_part "${part_type}" "${parts}"; then
|
||||
part="${parts}"
|
||||
else
|
||||
printf -- '%s\n' 'Which '"${part_type^^}"' partition do you want us to use?'
|
||||
while IFS= read -r found_part; do
|
||||
enriched_parts+=("'${found_part}'"' (aka ID '"'$(get_drive_id "${found_part}")'"')')
|
||||
done <<<"${parts}"
|
||||
enriched_parts_count="${#enriched_parts[@]}"
|
||||
select part in "${enriched_parts[@]}"; do
|
||||
part_number="${REPLY}"
|
||||
if [[ "${part_number}" -le "${enriched_parts_count}" ]]; then
|
||||
part="$(sed "${REPLY}q;d" <<<"${parts}")"
|
||||
printf -- '%s\n' 'You'"'"'ve selected '"'${part}'"' ...'
|
||||
break
|
||||
else
|
||||
printf -- '%s\n' 'Invalid option, please choose between 1 and '"${enriched_parts_count}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
printf -- '%s' "${part}"
|
||||
return 0
|
||||
}
|
||||
|
||||
function set_zpool_password () {
|
||||
# May or may not have a newline at the end, ZFS doesn't care
|
||||
printf -- '%s' 'password' > '/etc/zfs/'"${zpool_name}"'.key'
|
||||
|
Loading…
x
Reference in New Issue
Block a user