home · contact · privacy
Update Firefox.
[config] / all_new_2018 / setup_scripts / letsencrypt.sh
1 #!/bin/sh
2 # Certify current server with LetsEncrypt.
3 # Uses hostname -f for the domain we want to certify.
4 set -e
5
6 # Ensure we have a mail address as argument.
7 if [ $# -lt 1 ]; then
8     echo "Need mail address as argument."
9     false
10 fi
11 mail_address="$1"
12
13 # We need certbot to get LetsEncrypt certificates.
14 apt install -y certbot
15
16 # If port 80 blocked by iptables, open it.
17 set +e
18 iptables -C INPUT -p tcp --dport 80 -j ACCEPT
19 open_iptables="$?"
20 set -e
21 if [ "${open_iptables}" -eq "1" ]; then
22     iptables -A INPUT -p tcp --dport 80 -j ACCEPT
23 fi
24
25 # Create new certificate and copy it to /etc/letsencrypt.
26 certbot certonly --standalone --agree-tos -m "${mail_address}" -d "$(hostname -f)"
27
28 # Remove iptables rule to open port 80 if we added it.
29 if [ "${open_iptables}" -eq "1" ]; then
30     iptables -D INPUT -p tcp --dport 80 -j ACCEPT
31 fi