Export some crucial variables

This commit is contained in:
oddlama 2020-04-23 21:06:22 +02:00
parent 38437daebd
commit 826f232807
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
3 changed files with 16 additions and 17 deletions

View File

@ -26,15 +26,15 @@ USED_LUKS=false
# An array of disk related actions to perform
DISK_ACTIONS=()
# An associative array from disk id to a resolvable string
declare -A DISK_ID_TO_RESOLVABLE
declare -Ax DISK_ID_TO_RESOLVABLE
# An associative from uuid to device
declare -A DISK_UUID_TO_DEVICE
declare -Ax DISK_UUID_TO_DEVICE
# An associative array from disk id to parent gpt disk id (only for partitions)
declare -A DISK_ID_PART_TO_GPT_ID
declare -Ax DISK_ID_PART_TO_GPT_ID
# An associative array to check for existing ids (maps to uuids)
declare -A DISK_ID_TO_UUID
declare -Ax DISK_ID_TO_UUID
# An associative set to check for correct usage of size=remaining in gpt tables
declare -A DISK_GPT_HAD_SIZE_REMAINING
declare -Ax DISK_GPT_HAD_SIZE_REMAINING
only_one_of() {
local previous=""

View File

@ -119,12 +119,12 @@ install_kernel_bios() {
# Install syslinux MBR record
einfo "Copying syslinux MBR record"
local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")"
local gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_BIOS]}")"
try dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of="$gptdev"
# Install syslinux
einfo "Installing syslinux"
local biosdev="$(resolve_device_by_id "$DISK_ID_BIOS")"
syslinux --install "$biosdev"
}

View File

@ -138,12 +138,11 @@ get_device_by_uuid() {
get_device_by_blkid_field 'UUID' "$1"
}
get_device_by_ptuuid() {
echo -n "${DISK_UUID_TO_DEVICE[${1,,}]}"
}
get_device_by_mdadm_uuid() {
echo -n "${DISK_UUID_TO_DEVICE[${1,,}]}"
get_device_by_stored_uuid() {
local key="${1,,}"
[[ -v "DISK_UUID_TO_DEVICE[$key]" ]] \
|| die "Could not resolve uuid $key to device"
echo -n "${DISK_UUID_TO_DEVICE[$key]}"
}
get_device_by_luks_uuid() {
@ -206,8 +205,8 @@ resolve_device_by_id() {
'partuuid') get_device_by_partuuid "$arg" ;;
'ptuuid') get_device_by_ptuuid "$arg" ;;
'uuid') get_device_by_uuid "$arg" ;;
'mdadm') get_device_by_mdadm_uuid "$arg" ;;
'luks') get_device_by_luks_uuid "$arg" ;;
'mdadm') get_device_by_stored_uuid "$arg" ;;
'luks') get_device_by_stored_uuid "$arg" ;;
*) die "Cannot resolve '$type:$arg' to device (unknown type)"
esac
}