Skip to content

Commit

Permalink
Use long options in the cloud-init disk_setup.sh template
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mcdonnnj committed Apr 9, 2024
1 parent 13c76fd commit 8858e9c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions terraform/cloud-init/disk_setup.tpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -59,18 +59,18 @@ 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
#
# This is a Terraform template file, and the mount_options and mount_point
# 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
Expand Down

0 comments on commit 8858e9c

Please sign in to comment.