Skip to content

Instantly share code, notes, and snippets.

@genothomas
Forked from erikaheidi/nginx-userdata-centos.sh
Created November 17, 2019 14:07
Show Gist options
  • Save genothomas/920a3e038e3617ac1311c90dd6f1d9e0 to your computer and use it in GitHub Desktop.
Save genothomas/920a3e038e3617ac1311c90dd6f1d9e0 to your computer and use it in GitHub Desktop.
Simple shell script to install Nginx on CentOS using DigitalOcean's metadata/userdata
#!/bin/bash
yum install epel-release -y
yum install nginx -y
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
echo Droplet: $HOSTNAME, IP Address: $PUBLIC_IPV4 > /usr/share/nginx/html/index.html
systemctl enable nginx
systemctl start nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment