diff options
| author | Lexi Winter <ivy@FreeBSD.org> | 2025-06-03 09:53:49 +0100 |
|---|---|---|
| committer | Lexi Winter <ivy@FreeBSD.org> | 2025-06-03 09:53:49 +0100 |
| commit | 6e4bfc59487dbb9d5c80d2debe98f769fe244577 (patch) | |
| tree | 24f9386619f6068925e037b4254859acc0ecc0e0 /init.sh | |
| parent | 65401ae5872e76f5ceab0c0e808d1e4823c6c0dc (diff) | |
| download | lfacme-6e4bfc59487dbb9d5c80d2debe98f769fe244577.tar.gz lfacme-6e4bfc59487dbb9d5c80d2debe98f769fe244577.tar.bz2 | |
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.
Diffstat (limited to 'init.sh')
| -rw-r--r-- | init.sh | 47 |
1 files changed, 32 insertions, 15 deletions
@@ -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" "$@" +} |
