4 # Ensure we have a mail address as argument.
6 echo "Need mail address as argument."
11 # We need certbot to get LetsEncrypt certificates.
12 apt install -y certbot
14 # If port 80 blocked by iptables, open it.
16 iptables -C INPUT -p tcp --dport 80 -j ACCEPT
19 if [ "${open_iptables}" -eq "1" ]; then
20 iptables -A INPUT -p tcp --dport 80 -j ACCEPT
23 # Create new certificate and copy it to /etc/letsencrypt.
24 certbot certonly --standalone --agree-tos -m "${mail_address}" -d "$(hostname -f)"
26 # Remove iptables rule to open port 80 if we added it.
27 if [ "${open_iptables}" -eq "1" ]; then
28 iptables -D INPUT -p tcp --dport 80 -j ACCEPT