Skip to content

Commit 8be3465

Browse files
authored
Merge pull request #4061 from acmesh-official/dev
Dev
2 parents c8c1c09 + 8ba7d02 commit 8be3465

File tree

9 files changed

+226
-242
lines changed

9 files changed

+226
-242
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ RUN for verb in help \
6565
RUN printf "%b" '#!'"/usr/bin/env sh\n \
6666
if [ \"\$1\" = \"daemon\" ]; then \n \
6767
trap \"echo stop && killall crond && exit 0\" SIGTERM SIGINT \n \
68-
crond && while true; do sleep 1; done;\n \
68+
crond && sleep infinity &\n \
69+
wait \n \
6970
else \n \
7071
exec -- \"\$@\"\n \
7172
fi" >/entry.sh && chmod +x /entry.sh

acme.sh

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,9 @@ _base64() {
983983
#Usage: multiline
984984
_dbase64() {
985985
if [ "$1" ]; then
986-
${ACME_OPENSSL_BIN:-openssl} base64 -d -A
987-
else
988986
${ACME_OPENSSL_BIN:-openssl} base64 -d
987+
else
988+
${ACME_OPENSSL_BIN:-openssl} base64 -d -A
989989
fi
990990
}
991991

@@ -4530,7 +4530,7 @@ issue() {
45304530

45314531
response="$(echo "$response" | _normalizeJson)"
45324532
_debug2 response "$response"
4533-
_d="$(echo "$response" | _egrep_o '"value" *: *"[^"]*"' | cut -d : -f 2 | tr -d ' "')"
4533+
_d="$(echo "$response" | _egrep_o '"value" *: *"[^"]*"' | cut -d : -f 2- | tr -d ' "')"
45344534
if _contains "$response" "\"wildcard\" *: *true"; then
45354535
_d="*.$_d"
45364536
fi
@@ -4680,6 +4680,7 @@ $_authorizations_map"
46804680
_dns_root_d="$(echo "$_dns_root_d" | sed 's/*.//')"
46814681
fi
46824682
_d_alias="$(_getfield "$_challenge_alias" "$_alias_index")"
4683+
test "$_d_alias" = "$NO_VALUE" && _d_alias=""
46834684
_alias_index="$(_math "$_alias_index" + 1)"
46844685
_debug "_d_alias" "$_d_alias"
46854686
if [ "$_d_alias" ]; then
@@ -4974,7 +4975,7 @@ $_authorizations_map"
49744975
return 1
49754976
fi
49764977
_debug "sleep 2 secs to verify again"
4977-
sleep 2
4978+
_sleep 2
49784979
_debug "checking"
49794980

49804981
_send_signed_request "$uri"
@@ -5151,7 +5152,7 @@ $_authorizations_map"
51515152
Le_CertCreateTime=$(_time)
51525153
_savedomainconf "Le_CertCreateTime" "$Le_CertCreateTime"
51535154

5154-
Le_CertCreateTimeStr=$(date -u)
5155+
Le_CertCreateTimeStr=$(_time2str "$Le_CertCreateTime")
51555156
_savedomainconf "Le_CertCreateTimeStr" "$Le_CertCreateTimeStr"
51565157

51575158
if [ -z "$Le_RenewalDays" ] || [ "$Le_RenewalDays" -lt "0" ]; then
@@ -5249,7 +5250,8 @@ renew() {
52495250
fi
52505251

52515252
_isEcc="$2"
5252-
5253+
#the server specified from commandline
5254+
_acme_server_back="$ACME_DIRECTORY"
52535255
_initpath "$Le_Domain" "$_isEcc"
52545256
_set_level=${NOTIFY_LEVEL:-$NOTIFY_LEVEL_DEFAULT}
52555257
_info "$(__green "Renew: '$Le_Domain'")"
@@ -5270,35 +5272,36 @@ renew() {
52705272
Le_API="$CA_LETSENCRYPT_V2"
52715273
fi
52725274

5273-
#revert from staging CAs back to production CAs
5274-
if [ -z "$ACME_DIRECTORY" ]; then
5275-
case "$Le_API" in
5276-
5277-
"$CA_LETSENCRYPT_V2_TEST")
5278-
_info "Switching back to $CA_LETSENCRYPT_V2"
5279-
Le_API="$CA_LETSENCRYPT_V2"
5280-
;;
5281-
"$CA_BUYPASS_TEST")
5282-
_info "Switching back to $CA_BUYPASS"
5283-
Le_API="$CA_BUYPASS"
5284-
;;
5285-
"$CA_GOOGLE_TEST")
5286-
_info "Switching back to $CA_GOOGLE"
5287-
Le_API="$CA_GOOGLE"
5288-
;;
5289-
esac
5275+
if [ "$_acme_server_back" ]; then
5276+
export ACME_DIRECTORY="$_acme_server_back"
5277+
else
5278+
export ACME_DIRECTORY="$Le_API"
52905279
fi
52915280

5292-
if [ "$Le_API" ]; then
5281+
case "$Le_API" in
5282+
"$CA_LETSENCRYPT_V2_TEST")
5283+
_info "Switching back to $CA_LETSENCRYPT_V2"
5284+
Le_API="$CA_LETSENCRYPT_V2"
5285+
;;
5286+
"$CA_BUYPASS_TEST")
5287+
_info "Switching back to $CA_BUYPASS"
5288+
Le_API="$CA_BUYPASS"
5289+
;;
5290+
"$CA_GOOGLE_TEST")
5291+
_info "Switching back to $CA_GOOGLE"
5292+
Le_API="$CA_GOOGLE"
5293+
;;
5294+
esac
5295+
5296+
if [ "$Le_API" ] && [ "$ACME_DIRECTORY" ]; then
52935297
if [ "$Le_API" != "$ACME_DIRECTORY" ]; then
52945298
_clearAPI
52955299
fi
5296-
export ACME_DIRECTORY="$Le_API"
52975300
#reload ca configs
52985301
ACCOUNT_KEY_PATH=""
52995302
ACCOUNT_JSON_PATH=""
53005303
CA_CONF=""
5301-
_debug3 "initpath again."
5304+
_debug2 "initpath again."
53025305
_initpath "$Le_Domain" "$_isEcc"
53035306
fi
53045307

@@ -5544,10 +5547,13 @@ showcsr() {
55445547
_initpath
55455548

55465549
_csrsubj=$(_readSubjectFromCSR "$_csrfile")
5547-
if [ "$?" != "0" ] || [ -z "$_csrsubj" ]; then
5550+
if [ "$?" != "0" ]; then
55485551
_err "Can not read subject from csr: $_csrfile"
55495552
return 1
55505553
fi
5554+
if [ -z "$_csrsubj" ]; then
5555+
_info "The Subject is empty"
5556+
fi
55515557

55525558
_info "Subject=$_csrsubj"
55535559

@@ -6956,6 +6962,10 @@ _processAccountConf() {
69566962
}
69576963

69586964
_checkSudo() {
6965+
if [ -z "__INTERACTIVE" ]; then
6966+
#don't check if it's not in an interactive shell
6967+
return 0
6968+
fi
69596969
if [ "$SUDO_GID" ] && [ "$SUDO_COMMAND" ] && [ "$SUDO_USER" ] && [ "$SUDO_UID" ]; then
69606970
if [ "$SUDO_USER" = "root" ] && [ "$SUDO_UID" = "0" ]; then
69616971
#it's root using sudo, no matter it's using sudo or not, just fine

deploy/mailcow.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@ mailcow_deploy() {
2020
_debug _cca "$_cca"
2121
_debug _cfullchain "$_cfullchain"
2222

23-
_mailcow_path="${DEPLOY_MAILCOW_PATH}"
23+
_getdeployconf DEPLOY_MAILCOW_PATH
24+
_getdeployconf DEPLOY_MAILCOW_RELOAD
2425

25-
if [ -z "$_mailcow_path" ]; then
26+
_debug DEPLOY_MAILCOW_PATH "$DEPLOY_MAILCOW_PATH"
27+
_debug DEPLOY_MAILCOW_RELOAD "$DEPLOY_MAILCOW_RELOAD"
28+
29+
if [ -z "$DEPLOY_MAILCOW_PATH" ]; then
2630
_err "Mailcow path is not found, please define DEPLOY_MAILCOW_PATH."
2731
return 1
2832
fi
2933

30-
#Tests if _ssl_path is the mailcow root directory.
31-
if [ -f "${_mailcow_path}/generate_config.sh" ]; then
32-
_ssl_path="${_mailcow_path}/data/assets/ssl/"
33-
else
34-
_ssl_path="${_mailcow_path}"
34+
_savedeployconf DEPLOY_MAILCOW_PATH "$DEPLOY_MAILCOW_PATH"
35+
[ -n "$DEPLOY_MAILCOW_RELOAD" ] && _savedeployconf DEPLOY_MAILCOW_RELOAD "$DEPLOY_MAILCOW_RELOAD"
36+
37+
_ssl_path="$DEPLOY_MAILCOW_PATH"
38+
if [ -f "$DEPLOY_MAILCOW_PATH/generate_config.sh" ]; then
39+
_ssl_path="$DEPLOY_MAILCOW_PATH/data/assets/ssl/"
3540
fi
3641

3742
if [ ! -d "$_ssl_path" ]; then
@@ -40,16 +45,15 @@ mailcow_deploy() {
4045
fi
4146

4247
# ECC or RSA
43-
if [ -z "${Le_Keylength}" ]; then
44-
Le_Keylength=""
45-
fi
46-
if _isEccKey "${Le_Keylength}"; then
48+
length=$(_readdomainconf Le_Keylength)
49+
if _isEccKey "$length"; then
4750
_info "ECC key type detected"
4851
_cert_name_prefix="ecdsa-"
4952
else
5053
_info "RSA key type detected"
5154
_cert_name_prefix=""
5255
fi
56+
5357
_info "Copying key and cert"
5458
_real_key="$_ssl_path/${_cert_name_prefix}key.pem"
5559
if ! cat "$_ckey" >"$_real_key"; then
@@ -63,7 +67,7 @@ mailcow_deploy() {
6367
return 1
6468
fi
6569

66-
DEFAULT_MAILCOW_RELOAD="docker restart $(docker ps -qaf name=postfix-mailcow); docker restart $(docker ps -qaf name=nginx-mailcow); docker restart $(docker ps -qaf name=dovecot-mailcow)"
70+
DEFAULT_MAILCOW_RELOAD="docker restart \$(docker ps --quiet --filter name=nginx-mailcow --filter name=dovecot-mailcow)"
6771
_reload="${DEPLOY_MAILCOW_RELOAD:-$DEFAULT_MAILCOW_RELOAD}"
6872

6973
_info "Run reload: $_reload"

dnsapi/dns_1984hosting.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dns_1984hosting_add() {
4242

4343
_debug "Add TXT record $fulldomain with value '$txtvalue'"
4444
value="$(printf '%s' "$txtvalue" | _url_encode)"
45-
url="https://management.1984hosting.com/domains/entry/"
45+
url="https://1984.hosting/domains/entry/"
4646

4747
postdata="entry=new"
4848
postdata="$postdata&type=TXT"
@@ -95,7 +95,7 @@ dns_1984hosting_rm() {
9595
_debug _domain "$_domain"
9696
_debug "Delete $fulldomain TXT record"
9797

98-
url="https://management.1984hosting.com/domains"
98+
url="https://1984.hosting/domains"
9999
if ! _get_zone_id "$url" "$_domain"; then
100100
_err "invalid zone" "$_domain"
101101
return 1
@@ -138,7 +138,7 @@ _1984hosting_login() {
138138
_debug "Login to 1984Hosting as user $One984HOSTING_Username"
139139
username=$(printf '%s' "$One984HOSTING_Username" | _url_encode)
140140
password=$(printf '%s' "$One984HOSTING_Password" | _url_encode)
141-
url="https://management.1984hosting.com/accounts/checkuserauth/"
141+
url="https://1984.hosting/accounts/checkuserauth/"
142142

143143
response="$(_post "username=$username&password=$password&otpkey=" $url)"
144144
response="$(echo "$response" | _normalizeJson)"
@@ -175,7 +175,7 @@ _check_cookies() {
175175
return 1
176176
fi
177177

178-
_authget "https://management.1984hosting.com/accounts/loginstatus/"
178+
_authget "https://1984.hosting/accounts/loginstatus/"
179179
if _contains "$response" '"ok": true'; then
180180
_debug "Cached cookies still valid"
181181
return 0
@@ -204,7 +204,7 @@ _get_root() {
204204
return 1
205205
fi
206206

207-
_authget "https://management.1984hosting.com/domains/soacheck/?zone=$h&nameserver=ns0.1984.is."
207+
_authget "https://1984.hosting/domains/soacheck/?zone=$h&nameserver=ns0.1984.is."
208208
if _contains "$_response" "serial" && ! _contains "$_response" "null"; then
209209
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
210210
_domain="$h"
@@ -251,11 +251,11 @@ _htmlget() {
251251

252252
# add extra headers to request
253253
_authpost() {
254-
url="https://management.1984hosting.com/domains"
254+
url="https://1984.hosting/domains"
255255
_get_zone_id "$url" "$_domain"
256256
csrf_header="$(echo "$One984HOSTING_CSRFTOKEN_COOKIE" | _egrep_o "=[^=][0-9a-zA-Z]*" | tr -d "=")"
257257
export _H1="Cookie: $One984HOSTING_CSRFTOKEN_COOKIE;$One984HOSTING_SESSIONID_COOKIE"
258-
export _H2="Referer: https://management.1984hosting.com/domains/$_zone_id"
258+
export _H2="Referer: https://1984.hosting/domains/$_zone_id"
259259
export _H3="X-CSRFToken: $csrf_header"
260260
_response=$(_post "$1" "$2")
261261
}

0 commit comments

Comments
 (0)