Created
March 20, 2015 20:02
-
-
Save joshjdevl/3f900f275b414ffa0429 to your computer and use it in GitHub Desktop.
ec2 tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ $# -eq 0 ] | |
| then | |
| echo "No arguments supplied" | |
| exit -1 | |
| fi | |
| #SERVER=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)" --query 'Tags[*].Value' --output text) | |
| SERVER=$1 | |
| PRIVATE_IP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4) | |
| sudo sed -i "s/^\(HOSTNAME\s*=\s*\).*$/\1$SERVER/" /etc/sysconfig/network | |
| echo "$PRIVATE_IP $SERVER" | sudo tee --append /etc/hosts | |
| sudo reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment