aboutsummaryrefslogtreecommitdiffstats
path: root/init.sh
diff options
context:
space:
mode:
Diffstat (limited to 'init.sh')
-rw-r--r--init.sh47
1 files changed, 32 insertions, 15 deletions
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" "$@"
+}