2022-10-24 05:55:11 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) Edgeless Systems GmbH
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
set -euo pipefail
|
2022-11-10 04:28:35 -05:00
|
|
|
shopt -s extglob nullglob inherit_errexit
|
2022-10-24 05:55:11 -04:00
|
|
|
|
|
|
|
AWS_STATE_DISK_DEVICENAME="sdb"
|
|
|
|
AWS_STATE_DISK_SYMLINK="/dev/${AWS_STATE_DISK_DEVICENAME}"
|
|
|
|
|
|
|
|
# hack: aws nvme udev rules are never executed. Create symlinks for the nvme devices manually.
|
2022-11-10 08:17:04 -05:00
|
|
|
while [[ ! -L ${AWS_STATE_DISK_SYMLINK} ]]; do
|
|
|
|
for nvmedisk in /dev/nvme*n1; do
|
2023-01-17 15:25:04 -05:00
|
|
|
linkname=$(nvme amzn id-ctrl -b "${nvmedisk}" | tail -c +3073 | head -c 32 | tr -d ' ') || true
|
2022-11-10 08:17:04 -05:00
|
|
|
if [[ -n ${linkname} ]] && [[ ${linkname} == "${AWS_STATE_DISK_DEVICENAME}" ]]; then
|
|
|
|
ln -s "${nvmedisk}" "${AWS_STATE_DISK_SYMLINK}"
|
2022-10-24 05:55:11 -04:00
|
|
|
fi
|
2022-11-10 08:17:04 -05:00
|
|
|
done
|
|
|
|
if [[ -L ${AWS_STATE_DISK_SYMLINK} ]]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Waiting for state disk to appear.."
|
|
|
|
sleep 2
|
2022-10-24 05:55:11 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "AWS state disk found"
|
2022-11-10 04:28:35 -05:00
|
|
|
echo "${AWS_STATE_DISK_SYMLINK}" → "$(readlink -f "${AWS_STATE_DISK_SYMLINK}")"
|