From 7320cf4b083057af0b98907401d643d831d3accd Mon Sep 17 00:00:00 2001 From: Voop Date: Mon, 17 Jun 2024 09:44:13 +0300 Subject: [PATCH] Updated Certbot scripts --- .../scripts/letsencrypt/createLetsEncryptCert.sh | 14 ++++++++++++-- core_files/scripts/letsencrypt/renewAllCert.sh | 7 ++++++- install/install.sh | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core_files/scripts/letsencrypt/createLetsEncryptCert.sh b/core_files/scripts/letsencrypt/createLetsEncryptCert.sh index e3aefb4..2ee889f 100644 --- a/core_files/scripts/letsencrypt/createLetsEncryptCert.sh +++ b/core_files/scripts/letsencrypt/createLetsEncryptCert.sh @@ -16,7 +16,17 @@ if ! checkDir $sslDirPath; then mkdir -p $sslDirPath fi +CLOUDFLARE_OPTS="" +if [ -d "/cloudflare-account.ini" ]; then + CLOUDFLARE_OPTS+="--dns-cloudflare --dns-cloudflare-credentials /cloudflare-account.ini" +fi echo "Creating a cert for ${1}" -certbot certonly --config-dir $sslDirPath --webroot --webroot-path $certStuffRoot -n --agree-tos --register-unsafely-without-email -d ${1} -echo "End of script have a nice day! Enjoy you're new cert if it was created" \ No newline at end of file +certbot certonly --config-dir $sslDirPath --webroot --webroot-path $certStuffRoot $CLOUDFLARE_OPTS -n --agree-tos --register-unsafely-without-email -d ${1} +if [ $? -ne 0 ]; then + echo "[Failure] Unable to create certificate '${1}' due to an error" + exit 1 +else + echo "End of script have a nice day! Enjoy you're new cert if it was created" + exit 0 +fi diff --git a/core_files/scripts/letsencrypt/renewAllCert.sh b/core_files/scripts/letsencrypt/renewAllCert.sh index 4e7c0b4..2c021a7 100644 --- a/core_files/scripts/letsencrypt/renewAllCert.sh +++ b/core_files/scripts/letsencrypt/renewAllCert.sh @@ -26,4 +26,9 @@ if ! checkFile $logFile; then touch $logFile fi -/usr/bin/letsencrypt renew --config-dir $sslDirPath --webroot --webroot-path $certStuffRoot >> /scripts/letsencrypt/letsencrypt-renew.log \ No newline at end of file +CLOUDFLARE_OPTS="" +if [ -d "/cloudflare-account.ini" ]; then + CLOUDFLARE_OPTS+="--dns-cloudflare --dns-cloudflare-credentials /cloudflare-account.ini" +fi + +certbot renew $CLOUDFLARE_OPTS --config-dir $sslDirPath --webroot --webroot-path $certStuffRoot >> /scripts/letsencrypt/letsencrypt-renew.log \ No newline at end of file diff --git a/install/install.sh b/install/install.sh index 40cb1f5..c9db7de 100644 --- a/install/install.sh +++ b/install/install.sh @@ -3,7 +3,7 @@ apt-get update apt-get full-upgrade -y -apt-get install -y curl wget gnupg neovim nano vim emacs apt-utils iftop iptraf wget git zip tar unzip bmon iptraf socat bash-completion certbot cron inetutils-ping software-properties-common ca-certificates lsb-release apt-transport-https python3 python2 +apt-get install -y curl wget gnupg neovim nano vim emacs apt-utils iftop iptraf wget git zip tar unzip bmon iptraf socat bash-completion certbot cron inetutils-ping software-properties-common ca-certificates lsb-release apt-transport-https python3 python2 python3-certbot-dns-cloudflare sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -