letsencrypt-tools/install.sh

51 lines
1.5 KiB
Bash
Raw Normal View History

2021-04-14 11:17:00 -07:00
#!/bin/bash
# must be root
if [ "$USER" != "root" ]; then
echo "You must be root to run this installer."
exit
fi
2021-04-15 13:16:58 -07:00
# check for existing Let's Encrypt install
if [ -d "/etc/letsencrypt/" ]; then
echo "WARNING: Let's Encrypt is already installed."
echo "This installer will overwrite existing configurations."
echo -e "You have five seconds to execute ctrl-c to cancel this install.\a"
sleep 5
fi
2021-04-21 11:16:26 -07:00
apt-get update
2021-04-14 11:17:00 -07:00
apt-get -y install python3-certbot-apache
mkdir /etc/ssl/letsencrypt
chmod 750 /etc/ssl/letsencrypt
chgrp ssl-cert /etc/ssl/letsencrypt
2021-04-15 13:16:58 -07:00
# Let's Encrypt configurations
2021-04-14 11:17:00 -07:00
cp etc/letsencrypt/cli.ini /etc/letsencrypt/cli.ini
chmod 644 /etc/letsencrypt/cli.ini
chown root:root /etc/letsencrypt/cli.ini
mkdir -p /etc/letsencrypt/renewal-hooks/deploy/
cp etc/letsencrypt/renewal-hooks/deploy/cp-to-etc-ssl.sh /etc/letsencrypt/renewal-hooks/deploy/cp-to-etc-ssl.sh
chmod 750 /etc/letsencrypt/renewal-hooks/deploy/cp-to-etc-ssl.sh
chown root:root /etc/letsencrypt/renewal-hooks/deploy/cp-to-etc-ssl.sh
2021-04-21 10:05:13 -07:00
echo
2021-04-14 11:21:15 -07:00
domain=`hostname -d`
2021-04-14 11:17:00 -07:00
if [ -n "$domain" ]; then
echo "email = hostmaster@$domain" >> /etc/letsencrypt/cli.ini
2021-04-15 13:16:58 -07:00
echo "Let's Encrypt email set to hostmaster@$domain"
2021-04-14 11:17:00 -07:00
else
2021-04-21 10:05:13 -07:00
echo "Server DNS domain name not set, Let's Encrypt email setting left unconfigured."
2021-04-14 11:17:00 -07:00
fi
2021-04-21 10:05:13 -07:00
echo
2021-04-14 11:17:00 -07:00
cp etc/apache2/conf-available/certbot.conf /etc/apache2/conf-available/certbot.conf
2021-04-14 11:21:15 -07:00
a2enmod --quiet proxy
a2enconf --quiet certbot
2021-04-14 11:17:00 -07:00
systemctl restart apache2
2021-04-15 13:16:58 -07:00
# install Let's Encrypt user scripts
cp bin/letsencrypt-* /usr/local/bin
chmod 755 /usr/local/bin/letsencrypt-*