export state_dir=/etc/acme
export account_email=
export debug=0
-export challenge_dir='/var/run/acme/challenge'
+export run_dir=/var/run/acme
NFT_HANDLE=
HOOK=/usr/lib/acme/hook
LOG_TAG=acme
cleanup() {
log debug "cleaning up"
+ if [ -e $run_dir/lock ]; then
+ rm $run_dir/lock
+ fi
if [ "$NFT_HANDLE" ]; then
# $NFT_HANDLE contains the string 'handle XX' so pass it unquoted to nft
nft delete rule inet fw4 input $NFT_HANDLE
config_get webroot "$section" webroot
export webroot
if [ "$webroot" ]; then
- log warn "Option \"webroot\" is deprecated, please remove it and change your web server's config so it serves ACME challenge requests from /var/run/acme/challenge."
+ log warn "Option \"webroot\" is deprecated, please remove it and change your web server's config so it serves ACME challenge requests from $run_dir/challenge."
fi
}
return 1
}
+cmd_get() {
+ trap cleanup EXIT
+
+ config_load acme
+ config_foreach load_globals acme
+
+ config_foreach get_cert cert
+}
+
usage() {
cat <<EOF
Usage: acme <command> [arguments]
case $1 in
get)
- config_load acme
- config_foreach load_globals acme
-
- trap cleanup EXIT
- config_foreach get_cert cert
+ mkdir -p $run_dir
+ {
+ if ! flock -n 200; then
+ log err "Another ACME instance is already running."
+ exit 1
+ fi
+ cmd_get "$@"
+ } 200>$run_dir/lock
;;
*)
usage