-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
50 lines (36 loc) · 1015 Bytes
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# This script installs and configurs nginx
# it will listen on port 80, and will populate a simple html page with the node metadata
# install nginx
sudo apt-get update > /dev/null
sudo apt-get -y install nginx
# configure site
sudo bash -c "cat > /etc/nginx/sites-available/default << EOF
server {
listen 8080 default_server;
listen [::]:8080 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name localhost;
location / {
try_files \\\$uri \\\$uri/ /index.html;
}
}
EOF"
# configure index.html
sudo bash -c "cat > /var/www/html/index.html << EOF
<!DOCTYPE html>
<html>
<body>
<h3>instance index=$1</h3>
<p>
instance id=$(ec2metadata --instance-id) <br>
instance type=$(ec2metadata --instance-type) <br>
instance ip=$(ec2metadata --public-ipv4) <br>
instance region=$(ec2metadata --availability-zone | sed 's/.$//') <br>
</p>
</body>
</html>
EOF"
# restart nginx to apply changes
sudo /etc/init.d/nginx restart