From 8858e9cd7f979bf7878f970d8cd410cf3a668c12 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:45:44 -0400 Subject: [PATCH] Use long options in the cloud-init `disk_setup.sh` template Convert any short options with long alternatives. There is specifically an interaction with `mkfs` where the underlying filesystem handler does not appear to support long options but the "top-level" `mkfs` command does. Therefore one option is converted while the passed through option is not. --- terraform/cloud-init/disk_setup.tpl.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/terraform/cloud-init/disk_setup.tpl.sh b/terraform/cloud-init/disk_setup.tpl.sh index 2cb4bf72..625c2e80 100755 --- a/terraform/cloud-init/disk_setup.tpl.sh +++ b/terraform/cloud-init/disk_setup.tpl.sh @@ -21,12 +21,12 @@ set -o pipefail # templatefile(). # # shellcheck disable=SC2154 -while [ "$(lsblk | grep -c ' disk')" -lt "${num_disks}" ]; do +while [ "$(lsblk | grep --count ' disk')" -lt "${num_disks}" ]; do echo Waiting for disks to attach... sleep 5 done -nvme_devices=$(find /dev | grep -i 'nvme[0-9][1-9]\?n1$') +nvme_devices=$(find /dev | grep --ignore-case 'nvme[0-9][1-9]\?n1$') # Find our device from among the NVMe devices by checking each one's # vendor-specific region for the non-NVMe device name as it is @@ -45,7 +45,7 @@ for nvme_device in $nvme_devices; do # in via templatefile(). # # shellcheck disable=SC2154 - non_nvme_device_name=$(nvme id-ctrl -v "$nvme_device" | grep -o "${device_name}") + non_nvme_device_name=$(nvme id-ctrl --vendor-specific "$nvme_device" | grep --only-matching "${device_name}") set -o errexit set -o pipefail @@ -59,10 +59,10 @@ for nvme_device in $nvme_devices; do # are passed in via templatefile(). # # shellcheck disable=SC2154 - blkid -c /dev/null "$nvme_device" || mkfs -t "${fs_type}" -L "${label}" "$nvme_device" + blkid --cache-file /dev/null "$nvme_device" || mkfs --type "${fs_type}" -L "${label}" "$nvme_device" # Grab the UUID of this volume - uuid=$(blkid -s UUID -o value "$nvme_device") + uuid=$(blkid --match-tag UUID --output value "$nvme_device") # Mount the file system # @@ -70,7 +70,7 @@ for nvme_device in $nvme_devices; do # variables are passed in via templatefile(). # # shellcheck disable=SC2154 - mount UUID="$uuid" -o "${mount_options}" "${mount_point}" + mount UUID="$uuid" --options "${mount_options}" "${mount_point}" # Save the mount point in fstab, so the file system is # remounted if the instance is rebooted