Last active
August 29, 2015 14:16
-
-
Save TomMalbran/15c843650c1dc9019622 to your computer and use it in GitHub Desktop.
DigitalOcean Bash Script
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 | |
export IP=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address) | |
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname) | |
export LAST=${IP##*.} | |
HOSTNAME=${HOSTNAME/XXX/$LAST} | |
export HOST=${HOSTNAME%%.*} | |
export DOMAIN=${HOSTNAME/$HOST./} | |
sed -i "/HOSTNAME/c\HOSTNAME=${HOSTNAME}" /etc/sysconfig/network | |
sed -i "/127.0.0.1/a ${IP}\t${HOST}\t${HOSTNAME}\t${DOMAIN}" /etc/hosts | |
#cloud-config | |
output: {all: '| tee -a /var/log/cloud-init-output.log'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment