generated from UMM-CSci-3601/3601-iteration-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupdroplet.sh
executable file
·55 lines (50 loc) · 1.68 KB
/
setupdroplet.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
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
if [[ ! -e /swapfile ]]; then
echo "/swapfile does not exist, setting up swap"
# Set up swap space
fallocate -l 3G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab
echo 'vm.swappiness=10' >> /etc/sysctl.conf
else
echo "/swapfile already exists, skipping swap setup"
fi
ip="$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)"
domain="${ip}.nip.io"
echo
echo "Setting APP_HOST to ${domain}"
echo "APP_HOST=${domain}" > .env
echo
echo "Your site will be served over HTTPS automatically using Let's Encrypt."
echo "By continuing, you agree to the Let's Encrypt Subscriber Agreement at:"
echo "https://letsencrypt.org/documents/2017.11.15-LE-SA-v1.2.pdf"
while true; do
read -p "Do you agree to the terms? (y/n)" yn
case $yn in
[Yy]* ) agreed=true; break;;
[Nn]* ) agreed=false; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo "Setting APP_ACME_AGREE to ${agreed}"
echo "APP_ACME_AGREE=${agreed}" >> .env
if [ "${agreed}" = false ]; then
echo "TLS (HTTPS) will be disabled"
echo
echo "Your server is setup"
echo "Once you start it with 'docker-compose up -d' it will be available at:"
echo "http://${domain}"
else
echo
echo "Please enter your email address to signify agreement and to be notified"
echo "in case of issues. This will be used by Let's Encrypt."
read -p "Email address: " email
echo "Setting APP_TLS_EMAIL to ${email}"
echo "APP_TLS_EMAIL=${email}" >> .env
echo
echo "Your server is setup"
echo "Once you start it with 'docker-compose up -d' it will be available at:"
echo "https://${domain}"
fi