disk-from-cloud-image/gen-cloud-init/gen-hostname-and-instance-id.sh
Eliezer Croitoru 2705ea9243 2
2023-11-14 21:52:09 +02:00

13 lines
343 B
Bash

#!/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