diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-04 21:26:10 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-04 21:26:10 +0100 |
| commit | 403e010c5203a9ae418f4ed9636e4e56c6fafc02 (patch) | |
| tree | 7a35a494a78705ba2f8d949534ec3c2c256f24e5 /init.sh.in | |
| parent | 8ea6e4b3c555048e1cf5efdde2329df411894f48 (diff) | |
| download | lfacme-403e010c5203a9ae418f4ed9636e4e56c6fafc02.tar.gz lfacme-403e010c5203a9ae418f4ed9636e4e56c6fafc02.tar.bz2 | |
make program paths configurable
Diffstat (limited to 'init.sh.in')
| -rw-r--r-- | init.sh.in | 43 |
1 files changed, 40 insertions, 3 deletions
@@ -1,12 +1,14 @@ # This source code is released into the public domain. -_PROGNAME="$0" +_PROGNAME="${0##*/}" + +trap 'exit 1' TERM _fatal() { local _fmt=$1; shift local _msg="$(printf "$_fmt" "$@")" printf >&2 '%s: FATAL: %s\n' "$_PROGNAME" "$_msg" - exit 1 + kill $$ } _error() { @@ -80,16 +82,51 @@ fi if [ ! -d "$ACME_DATADIR" ]; then _info "creating directory %s" "$ACME_DATADIR" mkdir -p "$ACME_DATADIR" + if [ "$?" -ne 0 ]; then + exit 1 + fi fi # The domains.conf file. _DOMAINS="${_CONFDIR}/domains.conf" +# Find a program based on $PATH, or return the second argument if specified. +# If the program isn't found, print an error and exit. +_findbin() { + local cmd="$1" + local force="$2" + + if ! [ -z "$force" ]; then + if ! [ -x "$force" ]; then + _fatal "not found or not executable: %s" "$force" + fi + + echo $force + return 0 + fi + + local oIFS="$IFS" + local IFS=: + for dir in $PATH; do + local _bin="${dir}/${cmd}" + + if ! [ -x "$_bin" ]; then + continue + fi + + echo $_bin + return 0 + done + IFS="$oIFS" + + _fatal "required command '%s' not found" "$cmd" +} + # uacme's base directory; this is where it puts certificates. _UACME_DIR="${ACME_DATADIR}/certs" # The uacme executable. -_UACME=uacme +_UACME="$(_findbin uacme $ACME_UACME)" _LFACME_UACME_FLAGS="" if ! [ -z "$LFACME_VERBOSE" ]; then |
