Skip to content

Instantly share code, notes, and snippets.

@pacojp
Last active December 18, 2015 03:19
Show Gist options
  • Save pacojp/5716923 to your computer and use it in GitHub Desktop.
Save pacojp/5716923 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# this script expects user data field set like below.
#
#==========================
#hostname hogehostname
#somekey fugafuga
#==========================
#
USERDATA=`curl -s http://169.254.169.254/latest/user-data`
HOSTNAME=`echo ${USERDATA} | awk '/^hostname/{print $2}'`
if [ "${HOSTNAME}" != "" ]; then
echo "set hostname to ${HOSTNAME}"
hostname ${HOSTNAME}
else
echo "no hostname record found on user data"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment