Skip to content

Instantly share code, notes, and snippets.

@ivorscott
Created March 31, 2022 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivorscott/57b3dfca57c78c4aa26cfe23ad6ffddd to your computer and use it in GitHub Desktop.
Save ivorscott/57b3dfca57c78c4aa26cfe23ad6ffddd to your computer and use it in GitHub Desktop.
Ubuntu VM startup script
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
tpl="<html>
<head>
<title>Example</title>
<style>
.container {
font-family:arial;
padding: 15px;
}
.title {
color:#127FBF;
}
</style>
</head>
<body>
<div class='container'>
<h1 class='title'>Deployed with Terraform!</h1>
<ul>
<li>Internal hostname: $(hostname -f)</li>
</ul>
</div>
<script>
const publicName = document.location.hostname;
const list = document.getElementsByTagName('ul')[0];
const item = document.createElement('li');
const text = document.createTextNode('External hostname: ' + publicName);
item.appendChild(text);
list.appendChild(item);
</script>
</body>
</html>"
sudo echo $tpl > /var/www/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment