-#!/bin/bash
+#!/usr/bin/env bash
set -e
set -u
BASEDIR="${SCRIPTDIR}"
LETSENCRYPT="/etc/letsencrypt"
-# shellcheck disable=SC1090
-. "${SCRIPTDIR}/config.sh"
+eval "$("${SCRIPTDIR}/letsencrypt.sh" --env)"
+
+if [[ ! -e "${LETSENCRYPT}" ]]; then
+ echo "No existing letsencrypt files found."
+ exit 1
+fi
if [[ -e "${BASEDIR}/domains.txt" ]]; then
DOMAINS_TXT="${BASEDIR}/domains.txt"
fi
# Check if certificate still valid
- set +e; openssl x509 -checkend 0 -noout -in "${certdir}/cert.pem" > /dev/null 2> /dev/null; expired="${?}"; set -e
- if [[ "${expired}" = "1" ]]; then
+ if ! openssl x509 -checkend 0 -noout -in "${certdir}/cert.pem" >/dev/null 2>&1; then
echo " + Skipping: Certificate is expired."
continue
fi