Skip to content

Commit 9f369c4

Browse files
committed
update haproxy and acme from master
1 parent 1cde978 commit 9f369c4

10 files changed

Lines changed: 116 additions & 58 deletions

File tree

openwrt-22.03/patches/package/acme-acmesh/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=acme-acmesh
1111
PKG_VERSION:=3.0.1
12-
PKG_RELEASE:=$(AUTORELEASE)
12+
PKG_RELEASE:=10
1313

1414
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
1515
PKG_SOURCE_URL:=https://codeload.github.com/acmesh-official/acme.sh/tar.gz/$(PKG_VERSION)?
@@ -51,7 +51,7 @@ endef
5151
define Package/acme-acmesh-dnsapi
5252
SECTION:=net
5353
CATEGORY:=Network
54-
DEPENDS:=+acme
54+
DEPENDS:=+acme-acmesh
5555
TITLE:=DNS API integration for ACME (Letsencrypt) client
5656
PKGARCH:=all
5757
endef

openwrt-22.03/patches/package/acme-acmesh/files/hook.sh

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
set -u
33
ACME=/usr/lib/acme/client/acme.sh
44
LOG_TAG=acme-acmesh
5-
# webroot option deprecated, use the hardcoded value directly in the next major version
6-
WEBROOT=${webroot:-/var/run/acme/challenge}
5+
# webroot option deprecated, use the exported value directly in the next major version
6+
WEBROOT=${webroot:-$CHALLENGE_DIR}
7+
NOTIFY=/usr/lib/acme/notify
78

89
# shellcheck source=net/acme/files/functions.sh
910
. /usr/lib/acme/functions.sh
@@ -12,9 +13,33 @@ WEBROOT=${webroot:-/var/run/acme/challenge}
1213
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
1314
export NO_TIMESTAMP=1
1415

15-
cmd="$1"
16+
link_certs()
17+
{
18+
local main_domain
19+
local domain_dir
20+
domain_dir="$1"
21+
main_domain="$2"
1622

17-
case $cmd in
23+
(umask 077; cat "$domain_dir/fullchain.cer" "$domain_dir/$main_domain.key" > "$domain_dir/combined.cer")
24+
25+
if [ ! -e "$CERT_DIR/$main_domain.crt" ]; then
26+
ln -s "$domain_dir/$main_domain.cer" "$CERT_DIR/$main_domain.crt"
27+
fi
28+
if [ ! -e "$CERT_DIR/$main_domain.key" ]; then
29+
ln -s "$domain_dir/$main_domain.key" "$CERT_DIR/$main_domain.key"
30+
fi
31+
if [ ! -e "$CERT_DIR/$main_domain.fullchain.crt" ]; then
32+
ln -s "$domain_dir/fullchain.cer" "$CERT_DIR/$main_domain.fullchain.crt"
33+
fi
34+
if [ ! -e "$CERT_DIR/$main_domain.combined.crt" ]; then
35+
ln -s "$domain_dir/combined.cer" "$CERT_DIR/$main_domain.combined.crt"
36+
fi
37+
if [ ! -e "$CERT_DIR/$main_domain.chain.crt" ]; then
38+
ln -s "$domain_dir/ca.cer" "$CERT_DIR/$main_domain.chain.crt"
39+
fi
40+
}
41+
42+
case $1 in
1843
get)
1944
set --
2045
[ "$debug" = 1 ] && set -- "$@" --debug
@@ -38,20 +63,27 @@ get)
3863
staging_moved=1
3964
else
4065
set -- "$@" --renew --home "$state_dir" -d "$main_domain"
41-
log info "$*"
42-
trap 'ACTION=renewed-failed hotplug-call acme;exit 1' INT
43-
"$ACME" "$@"
66+
log info "$ACME $*"
67+
trap '$NOTIFY renew-failed;exit 1' INT
68+
$ACME "$@"
4469
status=$?
4570
trap - INT
4671

4772
case $status in
48-
0) ;; # renewed ok, handled by acme.sh hook, ignore.
49-
2) ;; # renew skipped, ignore.
73+
0)
74+
link_certs "$domain_dir" "$main_domain"
75+
$NOTIFY renewed
76+
exit
77+
;;
78+
2)
79+
# renew skipped, ignore.
80+
exit
81+
;;
5082
*)
51-
ACTION=renew-failed hotplug-call acme
83+
$NOTIFY renew-failed
84+
exit 1
5285
;;
5386
esac
54-
return 0
5587
fi
5688
fi
5789

@@ -83,6 +115,9 @@ get)
83115
elif [ "$calias" ]; then
84116
set -- "$@" --challenge-alias "$calias"
85117
fi
118+
if [ "$dns_wait" ]; then
119+
set -- "$@" --dnssleep "$dns_wait"
120+
fi
86121
elif [ "$standalone" = 1 ]; then
87122
set -- "$@" --standalone --listen-v6
88123
else
@@ -92,21 +127,18 @@ get)
92127

93128
set -- "$@" --issue --home "$state_dir"
94129

95-
log info "$*"
96-
trap 'ACTION=issue-failed hotplug-call acme;exit 1' INT
130+
log info "$ACME $*"
131+
trap '$NOTIFY issue-failed;exit 1' INT
97132
"$ACME" "$@" \
98-
--pre-hook 'ACTION=prepare hotplug-call acme' \
99-
--renew-hook 'ACTION=renewed hotplug-call acme'
133+
--pre-hook "$NOTIFY prepare" \
134+
--renew-hook "$NOTIFY renewed"
100135
status=$?
101136
trap - INT
102137

103138
case $status in
104139
0)
105-
ln -s "$domain_dir/$main_domain.cer" /etc/ssl/acme
106-
ln -s "$domain_dir/$main_domain.key" /etc/ssl/acme
107-
ln -s "$domain_dir/fullchain.cer" "/etc/ssl/acme/$main_domain.fullchain.cer"
108-
ln -s "$domain_dir/ca.cer" "/etc/ssl/acme/$main_domain.chain.cer"
109-
ACTION=issued hotplug-call acme
140+
link_certs "$domain_dir" "$main_domain"
141+
$NOTIFY issued
110142
;;
111143
*)
112144
if [ "$staging_moved" = 1 ]; then
@@ -117,8 +149,7 @@ get)
117149
mv "$domain_dir" "$failed_dir"
118150
log err "State moved to $failed_dir"
119151
fi
120-
ACTION=issue-failed hotplug-call acme
121-
return 0
152+
$NOTIFY issue-failed
122153
;;
123154
esac
124155
;;

openwrt-22.03/patches/package/acme-common/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=acme-common
11-
PKG_VERSION:=1.0.0
11+
PKG_VERSION:=1.0.2
1212

1313
PKG_MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
1414
PKG_LICENSE:=GPL-3.0-only
@@ -35,16 +35,19 @@ endef
3535

3636
define Package/acme-common/install
3737
$(INSTALL_DIR) $(1)/etc/acme
38+
$(INSTALL_DIR) $(1)/etc/ssl/acme
3839
$(INSTALL_DIR) $(1)/etc/config
3940
$(INSTALL_CONF) ./files/acme.config $(1)/etc/config/acme
4041
$(INSTALL_DIR) $(1)/usr/bin
4142
$(INSTALL_BIN) ./files/acme.sh $(1)/usr/bin/acme
4243
$(INSTALL_DIR) $(1)/usr/lib/acme
4344
$(INSTALL_DATA) ./files/functions.sh $(1)/usr/lib/acme
45+
$(INSTALL_BIN) ./files/acme-notify.sh $(1)/usr/lib/acme/notify
4446
$(INSTALL_DIR) $(1)/etc/init.d
4547
$(INSTALL_BIN) ./files/acme.init $(1)/etc/init.d/acme
4648
$(INSTALL_DIR) $(1)/etc/uci-defaults
4749
$(INSTALL_DATA) ./files/acme.uci-defaults $(1)/etc/uci-defaults/acme
50+
$(INSTALL_DIR) $(1)/etc/hotplug.d/acme
4851
endef
4952

5053
define Package/acme/postinst
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
set -u
3+
4+
event="$1"
5+
6+
# Call hotplug first, giving scripts a chance to modify certificates before
7+
# reloadaing the services
8+
ACTION=$event hotplug-call acme
9+
10+
case $event in
11+
renewed)
12+
ubus call service event '{"type":"acme.renew","data":{}}'
13+
;;
14+
issued)
15+
ubus call service event '{"type":"acme.issue","data":{}}'
16+
;;
17+
esac

openwrt-22.03/patches/package/acme-common/files/acme.config

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
config acme
2-
option state_dir '/etc/acme'
32
option account_email 'email@example.org'
43
option debug 0
54

65
config cert 'example_wildcard'
76
option enabled 0
8-
option use_staging 1
7+
option staging 1
98
list domains example.org
109
list domains sub.example.org
1110
list domains *.sub.example.org
@@ -17,6 +16,6 @@ config cert 'example_wildcard'
1716

1817
config cert 'example'
1918
option enabled 0
20-
option use_staging 1
19+
option staging 1
2120
list domains example.org
2221
list domains sub.example.org

openwrt-22.03/patches/package/acme-common/files/acme.sh

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
#
99
# Authors: Toke Høiland-Jørgensen <toke@toke.dk>
1010

11-
export state_dir='/etc/acme'
12-
export account_email=
13-
export debug=0
14-
export challenge_dir='/var/run/acme/challenge'
11+
run_dir=/var/run/acme
12+
export CHALLENGE_DIR=$run_dir/challenge
13+
export CERT_DIR=/etc/ssl/acme
1514
NFT_HANDLE=
1615
HOOK=/usr/lib/acme/hook
1716
LOG_TAG=acme
@@ -23,6 +22,9 @@ LOG_TAG=acme
2322

2423
cleanup() {
2524
log debug "cleaning up"
25+
if [ -e $run_dir/lock ]; then
26+
rm $run_dir/lock
27+
fi
2628
if [ "$NFT_HANDLE" ]; then
2729
# $NFT_HANDLE contains the string 'handle XX' so pass it unquoted to nft
2830
nft delete rule inet fw4 input $NFT_HANDLE
@@ -33,7 +35,7 @@ load_options() {
3335
section=$1
3436

3537
# compatibility for old option name
36-
config_get_bool use_staging "$section" staging
38+
config_get_bool staging "$section" use_staging
3739
if [ -z "$staging" ]; then
3840
config_get_bool staging "$section" staging 0
3941
fi
@@ -56,11 +58,13 @@ load_options() {
5658
export days
5759
config_get standalone "$section" standalone 0
5860
export standalone
61+
config_get dns_wait "$section" dns_wait
62+
export dns_wait
5963

6064
config_get webroot "$section" webroot
6165
export webroot
6266
if [ "$webroot" ]; then
63-
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."
67+
log warn "Option \"webroot\" is deprecated, please remove it and change your web server's config so it serves ACME challenge requests from $CHALLENGE_DIR."
6468
fi
6569
}
6670

@@ -76,7 +80,7 @@ get_cert() {
7680

7781
load_options "$section"
7882
if [ -z "$dns" ] && [ "$standalone" = 0 ]; then
79-
mkdir -p "$challenge_dir"
83+
mkdir -p "$CHALLENGE_DIR"
8084
fi
8185

8286
if [ "$standalone" = 1 ] && [ -z "$NFT_HANDLE" ]; then
@@ -102,11 +106,19 @@ load_globals() {
102106
log err "account_email option is required"
103107
exit 1
104108
fi
109+
export account_email
110+
111+
config_get state_dir "$section" state_dir
112+
if [ "$state_dir" ]; then
113+
log warn "Option \"state_dir\" is deprecated, please remove it. Certificates now exist in $CERT_DIR."
114+
mkdir -p "$state_dir"
115+
else
116+
state_dir=/etc/acme
117+
fi
118+
export state_dir
105119

106-
config_get state_dir "$section" state_dir "$state_dir"
107-
mkdir -p "$state_dir"
108-
109-
config_get debug "$section" debug "$debug"
120+
config_get debug "$section" debug 0
121+
export debug
110122

111123
# only look for the first acme section
112124
return 1
@@ -117,7 +129,6 @@ usage() {
117129
Usage: acme <command> [arguments]
118130
Commands:
119131
get issue or renew certificates
120-
cert <domain> show certificate matching domain
121132
EOF
122133
exit 1
123134
}
@@ -129,11 +140,18 @@ fi
129140

130141
case $1 in
131142
get)
143+
mkdir -p $run_dir
144+
exec 200>$run_dir/lock
145+
if ! flock -n 200; then
146+
log err "Another ACME instance is already running."
147+
exit 1
148+
fi
149+
150+
trap cleanup EXIT
151+
132152
config_load acme
133153
config_foreach load_globals acme
134154

135-
mkdir -p /etc/ssl/acme
136-
trap cleanup EXIT
137155
config_foreach get_cert cert
138156
;;
139157
*)

openwrt-22.03/patches/package/haproxy/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk
1111

1212
PKG_NAME:=haproxy
1313
PKG_VERSION:=2.6.6
14-
PKG_RELEASE:=$(AUTORELEASE)
14+
PKG_RELEASE:=104
1515

1616
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
1717
PKG_SOURCE_URL:=https://www.haproxy.org/download/2.6/src
@@ -122,8 +122,6 @@ define Package/haproxy/install
122122
$(INSTALL_CONF) ./files/haproxy.cfg $(1)/etc/
123123
$(INSTALL_DIR) $(1)/etc/init.d
124124
$(INSTALL_BIN) ./files/haproxy.init $(1)/etc/init.d/haproxy
125-
$(INSTALL_DIR) $(1)/etc/hotplug.d/acme
126-
$(INSTALL_DATA) ./files/acme.hotplug $(1)/etc/hotplug.d/acme/00-haproxy
127125
endef
128126

129127
Package/haproxy-nossl/install = $(Package/haproxy/install)

openwrt-22.03/patches/package/haproxy/files/acme.hotplug

Lines changed: 0 additions & 12 deletions
This file was deleted.

openwrt-22.03/patches/package/haproxy/files/haproxy.init

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ start_service() {
1818
procd_close_instance
1919
}
2020

21+
service_triggers() {
22+
procd_add_raw_trigger acme.renew 5000 /etc/init.d/haproxy reload
23+
}
24+
2125
extra_command "check" "Check haproxy config"
2226
check() {
2327
$HAPROXY_BIN -c -q -V -f $HAPROXY_CONFIG

openwrt-22.03/patches/package/haproxy/get-latest-patches.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
CLONEURL=https://git.haproxy.org/git/haproxy-2.6.git
4-
BASE_TAG=v2.6.2
4+
BASE_TAG=v2.6.6
55
TMP_REPODIR=tmprepo
66
PATCHESDIR=patches
77

0 commit comments

Comments
 (0)