disk-from-cloud-image/gen-cloud-init/gen-hostname-and-instance-id.sh

13 lines
343 B
Bash
Raw Normal View History

2023-11-14 21:52:09 +02:00
#!/usr/bin/env bash
OS_DISTRO="$1"
if [ -z "${OS_DISTRO}" ];then
OS_DISTRO="generic"
fi
INSTANCE_ID="$( uuidgen |cut -d '-' -f 1 )"
HOSTNAME="$(OS_DISTRO)-${INSTANCE_ID}"
cat meta-data | ruby replace.rb "##INSTANCE_ID##" "${INSTANCE_ID}" | ruby replace.rb "##HOSTNAME##" "${HOSTNAME}" > meta-data.in && \
cp -vf meta-data.in > meta-data