#!/usr/bin/env bash # Certbot Let's Encrypt Installer # Min. Requirement : GNU/Linux Ubuntu 16.04 # Last Build : 12/07/2019 # Author : MasEDI.Net (me@masedi.net) # 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 ) # shellcheck disable=SC1091 . "${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 DO_INSTALL_CERTBOT="y" else while [[ "${DO_INSTALL_CERTBOT}" != "y" && "${DO_INSTALL_CERTBOT}" != "n" ]]; do read -rp "Do you want to install Certbot Let's Encrypt client? [y/n]: " -i y -e DO_INSTALL_CERTBOT done fi if [[ ${DO_INSTALL_CERTBOT} == y* && ${INSTALL_CERTBOT} == true ]]; then echo "Installing Certbot Let's Encrypt client..." DISTRIB_NAME=${DISTRIB_NAME:-$(get_distrib_name)} RELEASE_NAME=${RELEASE_NAME:-$(get_release_name)} case "${DISTRIB_NAME}" in debian) case "${RELEASE_NAME}" in jessie) run apt-get install -qq -y certbot -t jessie-backports ;; stretch) run apt-get install -qq -y certbot -t stretch-backports ;; buster) run apt-get install -qq -y certbot ;; *) error "Unable to add Certbot, unsupported distribution release: ${DISTRIB_NAME^} ${RELEASE_NAME^}." echo "Sorry your system is not supported yet, installing from source may fix the issue." exit 1 ;; esac ;; ubuntu) case "${RELEASE_NAME}" in focal) run apt-get install -qq -y certbot ;; *) run add-apt-repository -y ppa:certbot/certbot run apt-get update -qq -y run apt-get install -qq -y certbot ;; esac ;; esac # Add Certbot auto renew command to cronjob. if "${DRYRUN}"; then info "Certbot auto-renew command added 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 <