#!/usr/bin/env bash # Certbot Let's Encrypt Installer # Min. Requirement : GNU/Linux Ubuntu 14.04 # Last Build : 12/07/2019 # Author : ESLabs.ID (eslabs.id@gmail.com) # Since Version : 1.0.0 # Include helper functions. if [ "$(type -t run)" != "function" ]; then BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) # shellchechk source=scripts/helper.sh # shellcheck disable=SC1090 . "${BASEDIR}/helper.sh" fi # Make sure only root can run this installer script. requires_root # Install Certbot Let's Encrypt. function init_certbotle_install() { if "${AUTO_INSTALL}"; then INSTALL_CERTBOT="y" else while [[ "${INSTALL_CERTBOT}" != "y" && "${INSTALL_CERTBOT}" != "n" ]]; do read -rp "Do you want to install Certbot Let's Encrypt client? [y/n]: " -e INSTALL_CERTBOT done fi if [[ "${INSTALL_CERTBOT}" == Y* || "${INSTALL_CERTBOT}" == y* ]]; then echo -e "\nInstalling Certbot Let's Encrypt client..." run add-apt-repository -y ppa:certbot/certbot run apt-get -y update run apt-get -y install certbot # Add Certbot auto renew command to cron #15 3 * * * /usr/bin/certbot renew --quiet --renew-hook "/bin/systemctl reload nginx" if "${DRYRUN}"; then status "Add Certbot auto-renew to cronjob in dryrun mode." else export EDITOR=nano CRONCMD='15 3 * * * /usr/bin/certbot renew --quiet --renew-hook "/usr/sbin/service nginx reload -s"' touch lemper.cron crontab -u root lemper.cron crontab -l > lemper.cron if ! grep -qwE "/usr/bin/certbot\ renew" lemper.cron; then cat >> lemper.cron <