From 6e4bfc59487dbb9d5c80d2debe98f769fe244577 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Tue, 3 Jun 2025 09:53:49 +0100 Subject: improve path handling - allow a different configuration directory to be specified with '-c' - since acme.conf allows the uacme directory to be changed, this allows the user to change both. - use /var/db/lfacme as the default datadir instead of putting data in /etc. --- init.sh | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'init.sh') diff --git a/init.sh b/init.sh index b1c9494..3c9de04 100644 --- a/init.sh +++ b/init.sh @@ -1,19 +1,7 @@ # This source code is released into the public domain. -_BASEDIR="/usr/local" -_SHARE="${_BASEDIR}/share/lfacme" -_CONFDIR="${_BASEDIR}/etc/lfacme" -_CONFIG="${_CONFDIR}/acme.conf" -_DOMAINS="${_CONFDIR}/domains.conf" -_UACME=/usr/local/bin/uacme -_UACME_DIR="${_CONFDIR}/certs" - _PROGNAME="$0" -_uacme() { - "$_UACME" -a "$ACME_URL" -c "$_UACME_DIR" "$@" -} - _fatal() { local _fmt=$1; shift local _msg="$(printf "$_fmt" "$@")" @@ -33,6 +21,22 @@ _warn() { printf >&2 '%s: WARNING: %s\n' "$_PROGNAME" "$_msg" } +# The prefix we're installed in. +_BASEDIR="/usr/local" +# Where the internal scripts are. +_SHARE="${_BASEDIR}/share/lfacme" + +# Our configuration directory. This might be overridden by command-line +# arguments. +if [ -z "$_CONFDIR" ]; then + _CONFDIR="${_BASEDIR}/etc/lfacme" +fi + +# Our configuration file. +_CONFIG="${_CONFDIR}/acme.conf" + +# Read and validate the configuration file. + if ! [ -f "$_CONFIG" ]; then _fatal "missing %s" "$_CONFIG" fi @@ -43,8 +47,8 @@ if [ -z "$ACME_URL" ]; then _fatal "ACME_URL must be set in %s" "$_CONFIG" fi -if [ -z "$ACME_DIR" ]; then - _fatal "ACME_DIR must be set in %s" "$_CONFIG" +if [ -z "$ACME_DATADIR" ]; then + ACME_DATADIR="/var/db/lfacme" fi if [ -z "$ACME_KERBEROS_PRINCIPAL" ]; then @@ -52,5 +56,18 @@ if [ -z "$ACME_KERBEROS_PRINCIPAL" ]; then fi if [ -z "$ACME_HOOKDIR" ]; then - ACME_HOOKDIR="${_CONFDIR}/hooks" + ACME_HOOKDIR="${ACME_CONFDIR}/hooks" fi + +# The domains.conf file. +_DOMAINS="${_CONFDIR}/domains.conf" + +# uacme's base directory; this is where it puts certificates. +_UACME_DIR="${ACME_DATADIR}/certs" + +# The uacme executable. +_UACME=/usr/local/bin/uacme + +_uacme() { + "$_UACME" -a "$ACME_URL" -c "$_UACME_DIR" "$@" +} -- cgit v1.2.3