Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
95a6c28d
Commit
95a6c28d
authored
Feb 19, 2017
by
neil
Committed by
GitHub
Feb 19, 2017
Browse files
Merge pull request #645 from Neilpang/dev
Dev
parents
e852044b
85e1f4ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
acme.sh
View file @
95a6c28d
...
...
@@ -2707,34 +2707,39 @@ _clearupwebbroot() {
}
_on_before_issue
()
{
_chk_web_roots
=
"
$1
"
_chk_main_domain
=
"
$2
"
_chk_alt_domains
=
"
$3
"
_chk_pre_hook
=
"
$4
"
_chk_local_addr
=
"
$5
"
_debug _on_before_issue
#run pre hook
if
[
"
$
Le_PreH
ook
"
]
;
then
_info
"Run pre hook:'
$
Le_PreH
ook
'"
if
[
"
$
_chk_pre_h
ook
"
]
;
then
_info
"Run pre hook:'
$
_chk_pre_h
ook
'"
if
!
(
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
Le_PreH
ook
"
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
_chk_pre_h
ook
"
)
;
then
_err
"Error when run pre hook."
return
1
fi
fi
if
_hasfield
"
$
Le_W
ebroot
"
"
$NO_VALUE
"
;
then
if
_hasfield
"
$
_chk_w
eb
_
root
s
"
"
$NO_VALUE
"
;
then
if
!
_exists
"nc"
;
then
_err
"Please install netcat(nc) tools first."
return
1
fi
fi
_debug Le_LocalAddress
"
$
Le_L
ocal
A
ddr
ess
"
_debug Le_LocalAddress
"
$
_chk_l
ocal
_a
ddr
"
alldomains
=
$(
echo
"
$
Le_Domain
,
$Le_Alt
"
|
tr
','
' '
)
alldomains
=
$(
echo
"
$
_chk_main_domain
,
$_chk_alt_domains
"
|
tr
','
' '
)
_index
=
1
_currentRoot
=
""
_addrIndex
=
1
for
d
in
$alldomains
;
do
_debug
"Check for domain"
"
$d
"
_currentRoot
=
"
$(
_getfield
"
$
Le_W
ebroot
"
$_index
)
"
_currentRoot
=
"
$(
_getfield
"
$
_chk_w
eb
_
root
s
"
$_index
)
"
_debug
"_currentRoot"
"
$_currentRoot
"
_index
=
$(
_math
$_index
+ 1
)
_checkport
=
""
...
...
@@ -2758,7 +2763,7 @@ _on_before_issue() {
if
[
"
$_checkport
"
]
;
then
_debug _checkport
"
$_checkport
"
_checkaddr
=
"
$(
_getfield
"
$
Le_L
ocal
A
ddr
ess
"
$_addrIndex
)
"
_checkaddr
=
"
$(
_getfield
"
$
_chk_l
ocal
_a
ddr
"
$_addrIndex
)
"
_debug _checkaddr
"
$_checkaddr
"
_addrIndex
=
"
$(
_math
$_addrIndex
+ 1
)
"
...
...
@@ -2777,7 +2782,7 @@ _on_before_issue() {
fi
done
if
_hasfield
"
$
Le_W
ebroot
"
"apache"
;
then
if
_hasfield
"
$
_chk_w
eb
_
root
s
"
"apache"
;
then
if
!
_setApache
;
then
_err
"set up apache error. Report error to me."
return
1
...
...
@@ -2789,6 +2794,7 @@ _on_before_issue() {
}
_on_issue_err
()
{
_chk_post_hook
=
"
$1
"
_debug _on_issue_err
if
[
"
$LOG_FILE
"
]
;
then
_err
"Please check log file for more details:
$LOG_FILE
"
...
...
@@ -2802,10 +2808,10 @@ _on_issue_err() {
fi
#run the post hook
if
[
"
$
Le_P
ost
H
ook
"
]
;
then
_info
"Run post hook:'
$
Le_P
ost
H
ook
'"
if
[
"
$
_chk_p
ost
_h
ook
"
]
;
then
_info
"Run post hook:'
$
_chk_p
ost
_h
ook
'"
if
!
(
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
Le_P
ost
H
ook
"
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
_chk_p
ost
_h
ook
"
)
;
then
_err
"Error when run post hook."
return
1
...
...
@@ -2814,12 +2820,14 @@ _on_issue_err() {
}
_on_issue_success
()
{
_chk_post_hook
=
"
$1
"
_chk_renew_hook
=
"
$2
"
_debug _on_issue_success
#run the post hook
if
[
"
$
Le_P
ost
H
ook
"
]
;
then
_info
"Run post hook:'
$
Le_P
ost
H
ook
'"
if
[
"
$
_chk_p
ost
_h
ook
"
]
;
then
_info
"Run post hook:'
$
_chk_p
ost
_h
ook
'"
if
!
(
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
Le_P
ost
H
ook
"
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
_chk_p
ost
_h
ook
"
)
;
then
_err
"Error when run post hook."
return
1
...
...
@@ -2827,10 +2835,10 @@ _on_issue_success() {
fi
#run renew hook
if
[
"
$IS_RENEW
"
]
&&
[
"
$
Le_R
enew
H
ook
"
]
;
then
_info
"Run renew hook:'
$
Le_R
enew
H
ook
'"
if
[
"
$IS_RENEW
"
]
&&
[
"
$
_chk_r
enew
_h
ook
"
]
;
then
_info
"Run renew hook:'
$
_chk_r
enew
_h
ook
'"
if
!
(
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
Le_R
enew
H
ook
"
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
_chk_r
enew
_h
ook
"
)
;
then
_err
"Error when run renew hook."
return
1
...
...
@@ -3027,38 +3035,38 @@ issue() {
_usage
"Usage:
$PROJECT_ENTRY
--issue -d a.com -w /path/to/webroot/a.com/ "
return
1
fi
Le_W
ebroot
=
"
$1
"
Le_D
omain
=
"
$2
"
Le_Alt
=
"
$3
"
if
_contains
"
$
Le_D
omain
"
","
;
then
Le_D
omain
=
$(
echo
"
$2
,
$3
"
|
cut
-d
,
-f
1
)
Le_Alt
=
$(
echo
"
$2
,
$3
"
|
cut
-d
,
-f
2- |
sed
"s/,
${
NO_VALUE
}
$/
/"
)
fi
Le_K
eylength
=
"
$4
"
Le_R
eal
C
ert
Path
=
"
$5
"
Le_RealKeyPath
=
"
$6
"
Le_RealCACertPath
=
"
$7
"
Le_R
eload
C
md
=
"
$8
"
Le_R
eal
F
ull
C
hain
Path
=
"
$9
"
Le_PreH
ook
=
"
${
10
}
"
Le_P
ost
H
ook
=
"
${
11
}
"
Le_R
enew
H
ook
=
"
${
12
}
"
Le_L
ocal
A
ddr
ess
=
"
${
13
}
"
_w
eb
_
root
s
=
"
$1
"
_main_d
omain
=
"
$2
"
_alt_domains
=
"
$3
"
if
_contains
"
$
_main_d
omain
"
","
;
then
_main_d
omain
=
$(
echo
"
$2
,
$3
"
|
cut
-d
,
-f
1
)
_alt_domains
=
$(
echo
"
$2
,
$3
"
|
cut
-d
,
-f
2- |
sed
"s/,
${
NO_VALUE
}
$/
/"
)
fi
_k
ey
_
length
=
"
$4
"
_r
eal
_c
ert
=
"
$5
"
_real_key
=
"
$6
"
_real_ca
=
"
$7
"
_r
eload
_c
md
=
"
$8
"
_r
eal
_f
ull
c
hain
=
"
$9
"
_pre_h
ook
=
"
${
10
}
"
_p
ost
_h
ook
=
"
${
11
}
"
_r
enew
_h
ook
=
"
${
12
}
"
_l
ocal
_a
ddr
=
"
${
13
}
"
#remove these later.
if
[
"
$
Le_W
ebroot
"
=
"dns-cf"
]
;
then
Le_W
ebroot
=
"dns_cf"
if
[
"
$
_w
eb
_
root
s
"
=
"dns-cf"
]
;
then
_w
eb
_
root
s
=
"dns_cf"
fi
if
[
"
$
Le_W
ebroot
"
=
"dns-dp"
]
;
then
Le_W
ebroot
=
"dns_dp"
if
[
"
$
_w
eb
_
root
s
"
=
"dns-dp"
]
;
then
_w
eb
_
root
s
=
"dns_dp"
fi
if
[
"
$
Le_W
ebroot
"
=
"dns-cx"
]
;
then
Le_W
ebroot
=
"dns_cx"
if
[
"
$
_w
eb
_
root
s
"
=
"dns-cx"
]
;
then
_w
eb
_
root
s
=
"dns_cx"
fi
_debug
"Using api:
$API
"
if
[
!
"
$IS_RENEW
"
]
;
then
_initpath
"
$
Le_D
omain
"
"
$
Le_K
eylength
"
_initpath
"
$
_main_d
omain
"
"
$
_k
ey
_
length
"
mkdir
-p
"
$DOMAIN_PATH
"
fi
...
...
@@ -3070,7 +3078,7 @@ issue() {
_debug _saved_domain
"
$_saved_domain
"
_saved_alt
=
$(
_readdomainconf Le_Alt
)
_debug _saved_alt
"
$_saved_alt
"
if
[
"
$_saved_domain
,
$_saved_alt
"
=
"
$
Le_Domain
,
$Le_Alt
"
]
;
then
if
[
"
$_saved_domain
,
$_saved_alt
"
=
"
$
_main_domain
,
$_alt_domains
"
]
;
then
_info
"Domains not changed."
_info
"Skip, Next renewal time is:
$(
__green
"
$(
_readdomainconf Le_NextRenewTimeStr
)
"
)
"
_info
"Add '
$(
__red
'--force'
)
' to force to renew."
...
...
@@ -3081,16 +3089,16 @@ issue() {
fi
fi
_savedomainconf
"Le_Domain"
"
$
Le_D
omain
"
_savedomainconf
"Le_Alt"
"
$
Le_Alt
"
_savedomainconf
"Le_Webroot"
"
$
Le_W
ebroot
"
_savedomainconf
"Le_Domain"
"
$
_main_d
omain
"
_savedomainconf
"Le_Alt"
"
$
_alt_domains
"
_savedomainconf
"Le_Webroot"
"
$
_w
eb
_
root
s
"
_savedomainconf
"Le_PreHook"
"
$
Le_PreH
ook
"
_savedomainconf
"Le_PostHook"
"
$
Le_P
ost
H
ook
"
_savedomainconf
"Le_RenewHook"
"
$
Le_R
enew
H
ook
"
_savedomainconf
"Le_PreHook"
"
$
_pre_h
ook
"
_savedomainconf
"Le_PostHook"
"
$
_p
ost
_h
ook
"
_savedomainconf
"Le_RenewHook"
"
$
_r
enew
_h
ook
"
if
[
"
$
Le_L
ocal
A
ddr
ess
"
]
;
then
_savedomainconf
"Le_LocalAddress"
"
$
Le_L
ocal
A
ddr
ess
"
if
[
"
$
_l
ocal
_a
ddr
"
]
;
then
_savedomainconf
"Le_LocalAddress"
"
$
_l
ocal
_a
ddr
"
else
_cleardomainconf
"Le_LocalAddress"
fi
...
...
@@ -3098,15 +3106,15 @@ issue() {
Le_API
=
"
$API
"
_savedomainconf
"Le_API"
"
$Le_API
"
if
[
"
$
Le_Alt
"
=
"
$NO_VALUE
"
]
;
then
Le_Alt
=
""
if
[
"
$
_alt_domains
"
=
"
$NO_VALUE
"
]
;
then
_alt_domains
=
""
fi
if
[
"
$
Le_K
eylength
"
=
"
$NO_VALUE
"
]
;
then
Le_K
eylength
=
""
if
[
"
$
_k
ey
_
length
"
=
"
$NO_VALUE
"
]
;
then
_k
ey
_
length
=
""
fi
if
!
_on_before_issue
;
then
if
!
_on_before_issue
"
$_web_roots
"
"
$_main_domain
"
"
$_alt_domains
"
"
$_pre_hook
"
"
$_local_addr
"
;
then
_err
"_on_before_issue."
return
1
fi
...
...
@@ -3116,7 +3124,7 @@ issue() {
if
[
-z
"
$_saved_account_key_hash
"
]
||
[
"
$_saved_account_key_hash
"
!=
"
$(
__calcAccountKeyHash
)
"
]
;
then
if
!
_regAccount
"
$_accountkeylength
"
;
then
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
else
...
...
@@ -3128,24 +3136,24 @@ issue() {
else
_key
=
$(
_readdomainconf Le_Keylength
)
_debug
"Read key length:
$_key
"
if
[
!
-f
"
$CERT_KEY_PATH
"
]
||
[
"
$
Le_K
eylength
"
!=
"
$_key
"
]
;
then
if
!
createDomainKey
"
$
Le_D
omain
"
"
$
Le_K
eylength
"
;
then
if
[
!
-f
"
$CERT_KEY_PATH
"
]
||
[
"
$
_k
ey
_
length
"
!=
"
$_key
"
]
;
then
if
!
createDomainKey
"
$
_main_d
omain
"
"
$
_k
ey
_
length
"
;
then
_err
"Create domain key error."
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
fi
if
!
_createcsr
"
$
Le_D
omain
"
"
$
Le_Alt
"
"
$CERT_KEY_PATH
"
"
$CSR_PATH
"
"
$DOMAIN_SSL_CONF
"
;
then
if
!
_createcsr
"
$
_main_d
omain
"
"
$
_alt_domains
"
"
$CERT_KEY_PATH
"
"
$CSR_PATH
"
"
$DOMAIN_SSL_CONF
"
;
then
_err
"Create CSR error."
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
fi
_savedomainconf
"Le_Keylength"
"
$
Le_K
eylength
"
_savedomainconf
"Le_Keylength"
"
$
_k
ey
_
length
"
vlist
=
"
$Le_Vlist
"
...
...
@@ -3153,12 +3161,12 @@ issue() {
sep
=
'#'
dvsep
=
','
if
[
-z
"
$vlist
"
]
;
then
alldomains
=
$(
echo
"
$
Le_Domain
,
$Le_Alt
"
|
tr
','
' '
)
alldomains
=
$(
echo
"
$
_main_domain
,
$_alt_domains
"
|
tr
','
' '
)
_index
=
1
_currentRoot
=
""
for
d
in
$alldomains
;
do
_info
"Getting webroot for domain"
"
$d
"
_w
=
"
$(
echo
$
Le_W
ebroot
|
cut
-d
,
-f
$_index
)
"
_w
=
"
$(
echo
$
_w
eb
_
root
s
|
cut
-d
,
-f
$_index
)
"
_debug _w
"
$_w
"
if
[
"
$_w
"
]
;
then
_currentRoot
=
"
$_w
"
...
...
@@ -3177,7 +3185,7 @@ issue() {
if
!
__get_domain_new_authz
"
$d
"
;
then
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3190,7 +3198,7 @@ issue() {
if
[
-z
"
$entry
"
]
;
then
_err
"Error, can not get domain token
$d
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
token
=
"
$(
printf
"%s
\n
"
"
$entry
"
| _egrep_o
'"token":"[^"]*'
|
cut
-d
:
-f
2 |
tr
-d
'"'
)
"
...
...
@@ -3271,7 +3279,7 @@ issue() {
if
[
"
$?
"
!=
"0"
]
;
then
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
dnsadded
=
'1'
...
...
@@ -3283,7 +3291,7 @@ issue() {
_debug
"Dns record not added yet, so, save to
$DOMAIN_CONF
and exit."
_err
"Please add the TXT records to the domains, and retry again."
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3329,12 +3337,12 @@ issue() {
if
[
"
$vtype
"
=
"
$VTYPE_HTTP
"
]
;
then
if
[
"
$_currentRoot
"
=
"
$NO_VALUE
"
]
;
then
_info
"Standalone mode server"
_ncaddr
=
"
$(
_getfield
"
$
Le_L
ocal
A
ddr
ess
"
"
$_ncIndex
"
)
"
_ncaddr
=
"
$(
_getfield
"
$
_l
ocal
_a
ddr
"
"
$_ncIndex
"
)
"
_ncIndex
=
"
$(
_math
$_ncIndex
+ 1
)
"
_startserver
"
$keyauthorization
"
"
$_ncaddr
"
&
if
[
"
$?
"
!=
"0"
]
;
then
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
serverproc
=
"
$!
"
...
...
@@ -3350,7 +3358,7 @@ issue() {
BACKUP_NGINX_CONF
=
""
if
!
_setNginx
"
$d
"
"
$_currentRoot
"
"
$thumbprint
"
;
then
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3385,7 +3393,7 @@ issue() {
_err
"
$d
:Can not write token to file :
$wellknown_path
/
$token
"
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3424,13 +3432,13 @@ issue() {
_SAN_B
=
"
$_x
.
$_y
.acme.invalid"
_debug2 _SAN_B
"
$_SAN_B
"
_ncaddr
=
"
$(
_getfield
"
$
Le_L
ocal
A
ddr
ess
"
"
$_ncIndex
"
)
"
_ncaddr
=
"
$(
_getfield
"
$
_l
ocal
_a
ddr
"
"
$_ncIndex
"
)
"
_ncIndex
=
"
$(
_math
"
$_ncIndex
"
+ 1
)
"
if
!
_starttlsserver
"
$_SAN_B
"
"
$_SAN_A
"
"
$Le_TLSPort
"
"
$keyauthorization
"
"
$_ncaddr
"
;
then
_err
"Start tls server error."
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
fi
...
...
@@ -3439,7 +3447,7 @@ issue() {
_err
"
$d
:Can not get challenge:
$response
"
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3447,7 +3455,7 @@ issue() {
_err
"
$d
:Challenge error:
$response
"
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3474,7 +3482,7 @@ issue() {
_err
"
$d
:Verify error:
$response
"
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
_debug2 original
"
$response
"
...
...
@@ -3509,7 +3517,7 @@ issue() {
fi
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3519,7 +3527,7 @@ issue() {
_err
"
$d
:Verify error:
$response
"
_clearupwebbroot
"
$_currentRoot
"
"
$removelevel
"
"
$token
"
_clearup
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3533,7 +3541,7 @@ issue() {
if
!
_send_signed_request
"
$API
/acme/new-cert"
"{
\"
resource
\"
:
\"
new-cert
\"
,
\"
csr
\"
:
\"
$der
\"
}"
"needbase64"
;
then
_err
"Sign failed."
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3575,7 +3583,7 @@ issue() {
if
[
-z
"
$Le_LinkCert
"
]
;
then
response
=
"
$(
echo
"
$response
"
| _dbase64
"multiline"
| _normalizeJson
)
"
_err
"Sign failed:
$(
echo
"
$response
"
| _egrep_o
'"detail":"[^"]*"'
)
"
_on_issue_err
_on_issue_err
"
$_post_hook
"
return
1
fi
...
...
@@ -3637,10 +3645,15 @@ issue() {
Le_NextRenewTime
=
$(
_math
"
$Le_NextRenewTime
"
- 86400
)
_savedomainconf
"Le_NextRenewTime"
"
$Le_NextRenewTime
"
_on_issue_success
_on_issue_success
"
$_post_hook
"
"
$_renew_hook
"
if
[
"
$Le_RealCertPath$Le_RealKeyPath$Le_RealCACertPath$Le_ReloadCmd$Le_RealFullChainPath
"
]
;
then
_installcert
if
[
"
$_real_cert$_real_key$_real_ca$_reload_cmd$_real_fullchain
"
]
;
then
_savedomainconf
"Le_RealCertPath"
"
$_real_cert
"
_savedomainconf
"Le_RealCACertPath"
"
$_real_ca
"
_savedomainconf
"Le_RealKeyPath"
"
$_real_key
"
_savedomainconf
"Le_ReloadCmd"
"
$_reload_cmd
"
_savedomainconf
"Le_RealFullChainPath"
"
$_real_fullchain
"
_installcert
"
$_main_domain
"
"
$_real_cert
"
"
$_real_key
"
"
$_real_ca
"
"
$_reload_cmd
"
"
$_real_fullchain
"
fi
}
...
...
@@ -3926,104 +3939,107 @@ deploy() {
}
installcert
()
{
Le_D
omain
=
"
$1
"
if
[
-z
"
$
Le_D
omain
"
]
;
then
_main_d
omain
=
"
$1
"
if
[
-z
"
$
_main_d
omain
"
]
;
then
_usage
"Usage:
$PROJECT_ENTRY
--installcert -d domain.com [--ecc] [--certpath cert-file-path] [--keypath key-file-path] [--capath ca-cert-file-path] [ --reloadCmd reloadCmd] [--fullchainpath fullchain-path]"
return
1
fi
Le_R
eal
C
ert
Path
=
"
$2
"
Le_RealKeyPath
=
"
$3
"
Le_RealCACertPath
=
"
$4
"
Le_R
eload
C
md
=
"
$5
"
Le_R
eal
F
ull
C
hain
Path
=
"
$6
"
_r
eal
_c
ert
=
"
$2
"
_real_key
=
"
$3
"
_real_ca
=
"
$4
"
_r
eload
_c
md
=
"
$5
"
_r
eal
_f
ull
c
hain
=
"
$6
"
_isEcc
=
"
$7
"
_initpath
"
$
Le_D
omain
"
"
$_isEcc
"
_initpath
"
$
_main_d
omain
"
"
$_isEcc
"
if
[
!
-d
"
$DOMAIN_PATH
"
]
;
then
_err
"Domain is not valid:'
$
Le_D
omain
'"
_err
"Domain is not valid:'
$
_main_d
omain
'"
return
1
fi
_installcert
_savedomainconf
"Le_RealCertPath"
"
$_real_cert
"
_savedomainconf
"Le_RealCACertPath"
"
$_real_ca
"
_savedomainconf
"Le_RealKeyPath"
"
$_real_key
"
_savedomainconf
"Le_ReloadCmd"
"
$_reload_cmd
"
_savedomainconf
"Le_RealFullChainPath"
"
$_real_fullchain
"
_installcert
"
$_main_domain
"
"
$_real_cert
"
"
$_real_key
"
"
$_real_ca
"
"
$_reload_cmd
"
"
$_real_fullchain
"
}
_installcert
()
{
_savedomainconf
"Le_RealCertPath"
"
$Le_RealCertPath
"
_savedomainconf
"Le_RealCACertPath"
"
$Le_RealCACertPath
"
_savedomainconf
"Le_RealKeyPath"
"
$Le_RealKeyPath
"
_savedomainconf
"Le_ReloadCmd"
"
$Le_ReloadCmd
"
_savedomainconf
"Le_RealFullChainPath"
"
$Le_RealFullChainPath
"
_main_domain
=
"
$1
"
_real_cert
=
"
$2
"
_real_key
=
"
$3
"
_real_ca
=
"
$4
"
_reload_cmd
=
"
$5
"
_real_fullchain
=
"
$6
"
if
[
"
$
Le_R
eal
C
ert
Path
"
=
"
$NO_VALUE
"
]
;
then
Le_R
eal
C
ert
Path
=
""
if
[
"
$
_r
eal
_c
ert
"
=
"
$NO_VALUE
"
]
;
then
_r
eal
_c
ert
=
""
fi
if
[
"
$
Le_RealKeyPath
"
=
"
$NO_VALUE
"
]
;
then
Le_RealKeyPath
=
""
if
[
"
$
_real_key
"
=
"
$NO_VALUE
"
]
;
then
_real_key
=
""
fi
if
[
"
$
Le_RealCACertPath
"
=
"
$NO_VALUE
"
]
;
then
Le_RealCACertPath
=
""
if
[
"
$
_real_ca
"
=
"
$NO_VALUE
"
]
;
then
_real_ca
=
""
fi
if
[
"
$
Le_R
eload
C
md
"
=
"
$NO_VALUE
"
]
;
then
Le_R
eload
C
md
=
""
if
[
"
$
_r
eload
_c
md
"
=
"
$NO_VALUE
"
]
;
then
_r
eload
_c
md
=
""
fi
if
[
"
$
Le_R
eal
F
ull
C
hain
Path
"
=
"
$NO_VALUE
"
]
;
then
Le_R
eal
F
ull
C
hain
Path
=
""
if
[
"
$
_r
eal
_f
ull
c
hain
"
=
"
$NO_VALUE
"
]
;
then
_r
eal
_f
ull
c
hain
=
""
fi
if
[
"
$Le_RealCertPath
"
]
;
then
_info
"Installing cert to:
$Le_RealCertPath
"
if
[
-f
"
$Le_RealCertPath
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
if
[
"
$_real_cert
"
]
;
then
_info
"Installing cert to:
$_real_cert
"
if
[
-f
"
$_real_cert
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
mkdir
-p
"
$DOMAIN_BACKUP_PATH
"
cp
"
$
Le_R
eal
C
ert
Path
"
"
$DOMAIN_BACKUP_PATH
/cert.bak"
cp
"
$
_r
eal
_c
ert
"
"
$DOMAIN_BACKUP_PATH
/cert.bak"
fi
cat
"
$CERT_PATH
"
>
"
$
Le_R
eal
C
ert
Path
"
cat
"
$CERT_PATH
"
>
"
$
_r
eal
_c
ert
"
fi
if
[
"
$Le_RealCACertPath
"
]
;
then
_info
"Installing CA to:
$Le_RealCACertPath
"
if
[
"
$Le_RealCACertPath
"
=
"
$Le_RealCertPath
"
]
;
then
echo
""
>>
"
$Le_RealCACertPath
"
cat
"
$CA_CERT_PATH
"
>>
"
$Le_RealCACertPath
"
if
[
"
$_real_ca
"
]
;
then
_info
"Installing CA to:
$_real_ca
"
if
[
"
$_real_ca
"
=
"
$_real_cert
"
]
;
then
echo
""
>>
"
$_real_ca
"
cat
"
$CA_CERT_PATH
"
>>
"
$_real_ca
"
else
if
[
-f
"
$
Le_RealCACertPath
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
if
[
-f
"
$
_real_ca
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
mkdir
-p
"
$DOMAIN_BACKUP_PATH
"
cp
"
$
Le_RealCACertPath
"
"
$DOMAIN_BACKUP_PATH
/ca.bak"
cp
"
$
_real_ca
"
"
$DOMAIN_BACKUP_PATH
/ca.bak"
fi
cat
"
$CA_CERT_PATH
"
>
"
$
Le_RealCACertPath
"
cat
"
$CA_CERT_PATH
"
>
"
$
_real_ca
"
fi
fi
if
[
"
$Le_RealKeyPath
"
]
;
then
_info
"Installing key to:
$Le_RealKeyPath
"
if
[
-f
"
$Le_RealKeyPath
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
if
[
"
$_real_key
"
]
;
then
_info
"Installing key to:
$_real_key
"
if
[
-f
"
$_real_key
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
mkdir
-p
"
$DOMAIN_BACKUP_PATH
"
cp
"
$
Le_RealKeyPath
"
"
$DOMAIN_BACKUP_PATH
/key.bak"
cp
"
$
_real_key
"
"
$DOMAIN_BACKUP_PATH
/key.bak"
fi
cat
"
$CERT_KEY_PATH
"
>
"
$
Le_RealKeyPath
"
cat
"
$CERT_KEY_PATH
"
>
"
$
_real_key
"
fi
if
[
"
$Le_RealFullChainPath
"
]
;
then
_info
"Installing full chain to:
$Le_RealFullChainPath
"
if
[
-f
"
$Le_RealFullChainPath
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
if
[
"
$_real_fullchain
"
]
;
then
_info
"Installing full chain to:
$_real_fullchain
"
if
[
-f
"
$_real_fullchain
"
]
&&
[
!
"
$IS_RENEW
"
]
;
then
mkdir
-p
"
$DOMAIN_BACKUP_PATH
"
cp
"
$
Le_R
eal
F
ull
C
hain
Path
"
"
$DOMAIN_BACKUP_PATH
/fullchain.bak"
cp
"
$
_r
eal
_f
ull
c
hain
"
"
$DOMAIN_BACKUP_PATH
/fullchain.bak"
fi
cat
"
$CERT_FULLCHAIN_PATH
"
>
"
$
Le_R
eal
F
ull
C
hain
Path
"
cat
"
$CERT_FULLCHAIN_PATH
"
>
"
$
_r
eal
_f
ull
c
hain
"
fi
if
[
"
$
Le_R
eload
C
md
"
]
;
then
_info
"Run
Le_R
eload
C
md:
$
Le_R
eload
C
md
"
if
[
"
$
_r
eload
_c
md
"
]
;
then
_info
"Run
r
eload
c
md:
$
_r
eload
_c
md
"
if
(
export
CERT_PATH
export
CERT_KEY_PATH
export
CA_CERT_PATH
export
CERT_FULLCHAIN_PATH
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
Le_R
eload
C
md
"
cd
"
$DOMAIN_PATH
"
&&
eval
"
$
_r
eload
_c
md
"
)
;
then
_info
"
$(
__green
"Reload success"
)
"
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment