die(){ echo "error: $1" >&2 exit 1 } set -e export HOME=/root cd "$HOME" echo "configuring hostname from aws metadata service" host_title="${AWS_STACK_NAME}-$(echo "${AWS_INSTANCE_LOGICAL_NAME}" | sed 's/LaunchConfiguration$//')" private_hostname=$(curl -sL http://169.254.169.254/latest/meta-data/local-hostname) short_private_hostname=$(echo "${private_hostname}" | cut -d'.' -f 1) echo "${host_title}" > /etc/hostname hostname -b -F /etc/hostname sed -i '/127\.0\./d' /etc/hosts cat >>/etc/hosts <