forked from openwrt/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openwrt#19669 from hgl/acme
acme: refactor
- Loading branch information
Showing
10 changed files
with
82 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=acme-common | ||
PKG_VERSION:=1.0.0 | ||
PKG_VERSION:=1.0.1 | ||
|
||
PKG_MAINTAINER:=Toke Høiland-Jørgensen <[email protected]> | ||
PKG_LICENSE:=GPL-3.0-only | ||
|
@@ -34,17 +34,19 @@ define Package/acme-common/conffiles | |
endef | ||
|
||
define Package/acme-common/install | ||
$(INSTALL_DIR) $(1)/etc/acme | ||
$(INSTALL_DIR) $(1)/etc/ssl/acme | ||
$(INSTALL_DIR) $(1)/etc/config | ||
$(INSTALL_CONF) ./files/acme.config $(1)/etc/config/acme | ||
$(INSTALL_DIR) $(1)/usr/bin | ||
$(INSTALL_BIN) ./files/acme.sh $(1)/usr/bin/acme | ||
$(INSTALL_DIR) $(1)/usr/lib/acme | ||
$(INSTALL_DATA) ./files/functions.sh $(1)/usr/lib/acme | ||
$(INSTALL_BIN) ./files/acme-notify.sh $(1)/usr/lib/acme/notify | ||
$(INSTALL_DIR) $(1)/etc/init.d | ||
$(INSTALL_BIN) ./files/acme.init $(1)/etc/init.d/acme | ||
$(INSTALL_DIR) $(1)/etc/uci-defaults | ||
$(INSTALL_DATA) ./files/acme.uci-defaults $(1)/etc/uci-defaults/acme | ||
$(INSTALL_DIR) $(1)/etc/hotplug.d/acme | ||
endef | ||
|
||
define Package/acme/postinst | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
set -u | ||
|
||
event="$1" | ||
|
||
# Call hotplug first, giving scripts a chance to modify certificates before | ||
# reloadaing the services | ||
ACTION=$event hotplug-call acme | ||
|
||
case $event in | ||
renewed) | ||
ubus call service event '{"type":"acme.renew","data":{}}' | ||
;; | ||
issued) | ||
ubus call service event '{"type":"acme.issue","data":{}}' | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,10 @@ | |
# | ||
# Authors: Toke Høiland-Jørgensen <[email protected]> | ||
|
||
export state_dir='/etc/acme' | ||
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 | ||
|
@@ -23,6 +23,9 @@ 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 | ||
|
@@ -33,7 +36,7 @@ load_options() { | |
section=$1 | ||
|
||
# compatibility for old option name | ||
config_get_bool use_staging "$section" staging | ||
config_get_bool staging "$section" use_staging | ||
if [ -z "$staging" ]; then | ||
config_get_bool staging "$section" staging 0 | ||
fi | ||
|
@@ -56,11 +59,13 @@ load_options() { | |
export days | ||
config_get standalone "$section" standalone 0 | ||
export standalone | ||
config_get dns_wait "$section" dns_wait | ||
export dns_wait | ||
|
||
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 | ||
} | ||
|
||
|
@@ -112,6 +117,15 @@ load_globals() { | |
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] | ||
|
@@ -128,12 +142,14 @@ fi | |
|
||
case $1 in | ||
get) | ||
config_load acme | ||
config_foreach load_globals acme | ||
|
||
mkdir -p /etc/ssl/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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters