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
95cdb4b2
Commit
95cdb4b2
authored
Mar 20, 2019
by
temoffey
Browse files
fix syntax
parent
228c8354
Changes
2
Show whitespace changes
Inline
Side-by-side
deploy/README.md
View file @
95cdb4b2
...
@@ -392,9 +392,9 @@ acme.sh --deploy --deploy-hook mydevil -d example.com
...
@@ -392,9 +392,9 @@ acme.sh --deploy --deploy-hook mydevil -d example.com
That will remove old certificate and install new one.
That will remove old certificate and install new one.
## 15. Deploy the cert to G-Core CDN servi
s
e
## 15. Deploy the cert to G-Core CDN servi
c
e
Deploy the cert to G-Core CDN servi
s
e (https://gcorelabs.com/ru/) using the G-Core Labs API (https://docs.gcorelabs.com/cdn/).
Deploy the cert to G-Core CDN servi
c
e (https://gcorelabs.com/ru/) using the G-Core Labs API (https://docs.gcorelabs.com/cdn/).
Uses command line curl for send requests and jq for parse responses.
Uses command line curl for send requests and jq for parse responses.
Then you can deploy now:
Then you can deploy now:
...
...
deploy/gcore_cdn.sh
View file @
95cdb4b2
#!/usr/bin/env sh
#!/usr/bin/env sh
# Here is the script to deploy the cert to G-Core CDN servi
s
e (https://gcorelabs.com/ru/) using the G-Core Labs API (https://docs.gcorelabs.com/cdn/).
# Here is the script to deploy the cert to G-Core CDN servi
c
e (https://gcorelabs.com/ru/) using the G-Core Labs API (https://docs.gcorelabs.com/cdn/).
# Uses command line curl for send requests and jq for parse responses.
# Uses command line curl for send requests and jq for parse responses.
# Returns 0 when success.
# Returns 0 when success.
#
#
...
@@ -37,22 +37,20 @@ gcore_cdn_deploy() {
...
@@ -37,22 +37,20 @@ gcore_cdn_deploy() {
if
[
-z
"
$Le_Deploy_gcore_cdn_username
"
]
;
then
if
[
-z
"
$Le_Deploy_gcore_cdn_username
"
]
;
then
_err
"Please define the target username: export DEPLOY_GCORE_CDN_USERNAME=username"
_err
"Please define the target username: export DEPLOY_GCORE_CDN_USERNAME=username"
return
1
return
1
else
DEPLOY_GCORE_CDN_USERNAME
=
"
$Le_Deploy_gcore_cdn_username
"
fi
fi
else
else
_savedomainconf Le_Deploy_gcore_cdn_username
"
$DEPLOY_GCORE_CDN_USERNAME
"
Le_Deploy_gcore_cdn_username
=
"
$DEPLOY_GCORE_CDN_USERNAME
"
_savedomainconf Le_Deploy_gcore_cdn_username
"
$Le_Deploy_gcore_cdn_username
"
fi
fi
if
[
-z
"
$DEPLOY_GCORE_CDN_PASSWORD
"
]
;
then
if
[
-z
"
$DEPLOY_GCORE_CDN_PASSWORD
"
]
;
then
if
[
-z
"
$Le_Deploy_gcore_cdn_password
"
]
;
then
if
[
-z
"
$Le_Deploy_gcore_cdn_password
"
]
;
then
_err
"Please define the target password: export DEPLOY_GCORE_CDN_PASSWORD=password"
_err
"Please define the target password: export DEPLOY_GCORE_CDN_PASSWORD=password"
return
1
return
1
else
DEPLOY_GCORE_CDN_PASSWORD
=
"
$Le_Deploy_gcore_cdn_password
"
fi
fi
else
else
_savedomainconf Le_Deploy_gcore_cdn_password
"
$DEPLOY_GCORE_CDN_PASSWORD
"
Le_Deploy_gcore_cdn_password
=
"
$DEPLOY_GCORE_CDN_PASSWORD
"
_savedomainconf Le_Deploy_gcore_cdn_password
"
$Le_Deploy_gcore_cdn_password
"
fi
fi
if
!
[
-x
"
$(
command
-v
jq
)
"
]
;
then
if
!
[
-x
"
$(
command
-v
jq
)
"
]
;
then
...
@@ -61,14 +59,14 @@ gcore_cdn_deploy() {
...
@@ -61,14 +59,14 @@ gcore_cdn_deploy() {
fi
fi
_info
"Get authorization token"
_info
"Get authorization token"
_request
=
"{
\"
username
\"
:
\"
$
DEPLOY_GCORE_CDN_USERNAME
\"
,
\"
password
\"
:
\"
$DEPLOY_GCORE_CDN_PASSWORD
\"
}"
_request
=
"{
\"
username
\"
:
\"
$
Le_Deploy_gcore_cdn_username
\"
,
\"
password
\"
:
\"
$Le_Deploy_gcore_cdn_password
\"
}"
_debug _request
"
$_request
"
_debug _request
"
$_request
"
_response
=
$(
curl
-s
-X
POST https://api.gcdn.co/auth/signin
-H
"Content-Type:application/json"
-d
"
$_request
"
)
_response
=
$(
curl
-s
-X
POST https://api.gcdn.co/auth/signin
-H
"Content-Type:application/json"
-d
"
$_request
"
)
_debug _response
"
$_response
"
_debug _response
"
$_response
"
_token
=
$(
echo
"
$_response
"
| jq
-r
'.token'
)
_token
=
$(
echo
"
$_response
"
| jq
-r
'.token'
)
_debug _token
"
$_token
"
_debug _token
"
$_token
"
if
[
"
$_token
"
=
=
"null"
]
;
then
if
[
"
$_token
"
=
"null"
]
;
then
_err
"Error G-Core Labs API authorization"
_err
"Error G-Core Labs API authorization"
return
1
return
1
fi
fi
...
@@ -85,7 +83,7 @@ gcore_cdn_deploy() {
...
@@ -85,7 +83,7 @@ gcore_cdn_deploy() {
_debug _sslDataOld
"
$_sslDataOld
"
_debug _sslDataOld
"
$_sslDataOld
"
_debug _originGroup
"
$_originGroup
"
_debug _originGroup
"
$_originGroup
"
if
[
-z
"
$_resourceId
"
]
||
[
"
$_resourceId
"
=
=
"null"
]
||
[
-z
"
$_originGroup
"
]
||
[
"
$_originGroup
"
=
=
"null"
]
;
then
if
[
-z
"
$_resourceId
"
]
||
[
"
$_resourceId
"
=
"null"
]
||
[
-z
"
$_originGroup
"
]
||
[
"
$_originGroup
"
=
"null"
]
;
then
_err
"Not found CDN resource with cname
$_cdomain
"
_err
"Not found CDN resource with cname
$_cdomain
"
return
1
return
1
fi
fi
...
@@ -107,7 +105,7 @@ gcore_cdn_deploy() {
...
@@ -107,7 +105,7 @@ gcore_cdn_deploy() {
_info
"Update CDN resource"
_info
"Update CDN resource"
_request
=
"{
\"
originGroup
\"
:
$_originGroup
,
\"
sslData
\"
:
$_sslDataAdd
}"
_request
=
"{
\"
originGroup
\"
:
$_originGroup
,
\"
sslData
\"
:
$_sslDataAdd
}"
_debug _request
"
$_request
"
_debug _request
"
$_request
"
_response
=
$(
curl
-s
-X
PUT https://api.gcdn.co/resources/
$_resourceId
-H
"Content-Type:application/json"
-H
"Authorization:Token
$_token
"
-d
"
$_request
"
)
_response
=
$(
curl
-s
-X
PUT
"
https://api.gcdn.co/resources/
$_resourceId
"
-H
"Content-Type:application/json"
-H
"Authorization:Token
$_token
"
-d
"
$_request
"
)
_debug _response
"
$_response
"
_debug _response
"
$_response
"
_sslDataNew
=
$(
echo
"
$_response
"
| jq
-r
'.sslData'
)
_sslDataNew
=
$(
echo
"
$_response
"
| jq
-r
'.sslData'
)
_debug _sslDataNew
"
$_sslDataNew
"
_debug _sslDataNew
"
$_sslDataNew
"
...
@@ -121,7 +119,7 @@ gcore_cdn_deploy() {
...
@@ -121,7 +119,7 @@ gcore_cdn_deploy() {
_info
"Not found old SSL certificate"
_info
"Not found old SSL certificate"
else
else
_info
"Delete old SSL certificate"
_info
"Delete old SSL certificate"
_response
=
$(
curl
-s
-X
DELETE https://api.gcdn.co/sslData/
$_sslDataOld
-H
"Authorization:Token
$_token
"
)
_response
=
$(
curl
-s
-X
DELETE
"
https://api.gcdn.co/sslData/
$_sslDataOld
"
-H
"Authorization:Token
$_token
"
)
_debug _response
"
$_response
"
_debug _response
"
$_response
"
fi
fi
...
...
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