mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-08 22:15:19 +02:00
Check for config file in various locations
This commit is contained in:
+6
-2
@@ -5,6 +5,10 @@
|
|||||||
# #
|
# #
|
||||||
# This file is looked for in the following locations: #
|
# This file is looked for in the following locations: #
|
||||||
# $SCRIPTDIR/config.sh (next to this script) #
|
# $SCRIPTDIR/config.sh (next to this script) #
|
||||||
|
# ${HOME}/.letsencrypt.sh/config.sh (in user home) #
|
||||||
|
# /usr/local/etc/letsencrypt.sh/config.sh #
|
||||||
|
# /etc/letsencrypt.sh/config.sh #
|
||||||
|
# ${PWD}/config.sh (in current working-directory) #
|
||||||
# #
|
# #
|
||||||
# Default values of this config are in comments #
|
# Default values of this config are in comments #
|
||||||
########################################################
|
########################################################
|
||||||
@@ -18,8 +22,8 @@
|
|||||||
# Default keysize for private keys (default: 4096)
|
# Default keysize for private keys (default: 4096)
|
||||||
#KEYSIZE="4096"
|
#KEYSIZE="4096"
|
||||||
|
|
||||||
# Base directory for account key, generated certificates and list of domains (default: $SCRIPTDIR)
|
# Base directory for account key, generated certificates and list of domains (default: $SCRIPTDIR -- uses config directory if undefined)
|
||||||
#BASEDIR="${SCRIPTDIR}"
|
#BASEDIR=$SCRIPTDIR
|
||||||
|
|
||||||
# Path to openssl config file (default: <unset> - tries to figure out system default)
|
# Path to openssl config file (default: <unset> - tries to figure out system default)
|
||||||
#OPENSSL_CNF=
|
#OPENSSL_CNF=
|
||||||
|
|||||||
+17
-3
@@ -20,10 +20,23 @@ OPENSSL_CNF="$(openssl version -d | cut -d'"' -f2)/openssl.cnf"
|
|||||||
ROOTCERT="lets-encrypt-x1-cross-signed.pem"
|
ROOTCERT="lets-encrypt-x1-cross-signed.pem"
|
||||||
CONTACT_EMAIL=
|
CONTACT_EMAIL=
|
||||||
|
|
||||||
# If exists load config from same directory as this script
|
# Check for config in various locations
|
||||||
if [[ -e "${BASEDIR}/config.sh" ]]; then
|
CONFIG=""
|
||||||
|
for check_config in "${SCRIPTDIR}" "${HOME}/.letsencrypt.sh" "/usr/local/etc/letsencrypt.sh" "/etc/letsencrypt.sh" "${PWD}"; do
|
||||||
|
if [[ -e "${check_config}/config.sh" ]]; then
|
||||||
|
BASEDIR="${check_config}"
|
||||||
|
CONFIG="${check_config}/config.sh"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z "${CONFIG}" ]]; then
|
||||||
|
echo "WARNING: No config file found, using default config!"
|
||||||
|
sleep 2
|
||||||
|
else
|
||||||
|
echo "Using config file ${check_config}"
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
. "${BASEDIR}/config.sh"
|
. "${CONFIG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove slash from end of BASEDIR. Mostly for cleaner outputs, doesn't change functionality.
|
# Remove slash from end of BASEDIR. Mostly for cleaner outputs, doesn't change functionality.
|
||||||
@@ -34,6 +47,7 @@ umask 077 # paranoid umask, we're creating private keys
|
|||||||
# Export some environment variables to be used in hook script
|
# Export some environment variables to be used in hook script
|
||||||
export WELLKNOWN
|
export WELLKNOWN
|
||||||
export BASEDIR
|
export BASEDIR
|
||||||
|
export CONFIG
|
||||||
|
|
||||||
anti_newline() {
|
anti_newline() {
|
||||||
tr -d '\n\r'
|
tr -d '\n\r'
|
||||||
|
|||||||
Reference in New Issue
Block a user