Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
dfe80556
Unverified
Commit
dfe80556
authored
Jun 28, 2022
by
lufi42
Committed by
GitHub
Jun 28, 2022
Browse files
Merge branch 'acmesh-official:dev' into dev
parents
6d2ab4d2
6ccf617d
Changes
40
Expand all
Hide whitespace changes
Inline
Side-by-side
.github/FUNDING.yml
View file @
dfe80556
...
...
@@ -3,7 +3,7 @@
github
:
# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon
:
# Replace with a single Patreon username
open_collective
:
acmesh
ko_fi
:
# Replace with a single Ko-fi username
ko_fi
:
neilpang
tidelift
:
# Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge
:
# Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay
:
# Replace with a single Liberapay username
...
...
.github/workflows/FreeBSD.yml
View file @
dfe80556
...
...
@@ -25,11 +25,11 @@ jobs:
CA
:
"
"
CA_EMAIL
:
"
"
TEST_PREFERRED_CHAIN
:
(STAGING) Pretend Pear X1
-
TEST_ACME_Server
:
"
ZeroSSL.com"
CA_ECDSA
:
"
ZeroSSL
ECC
Domain
Secure
Site
CA"
CA
:
"
ZeroSSL
RSA
Domain
Secure
Site
CA"
CA_EMAIL
:
"
githubtest@acme.sh"
TEST_PREFERRED_CHAIN
:
"
"
#
- TEST_ACME_Server: "ZeroSSL.com"
#
CA_ECDSA: "ZeroSSL ECC Domain Secure Site CA"
#
CA: "ZeroSSL RSA Domain Secure Site CA"
#
CA_EMAIL: "githubtest@acme.sh"
#
TEST_PREFERRED_CHAIN: ""
runs-on
:
macos-10.15
env
:
TEST_LOCAL
:
1
...
...
.github/workflows/Linux.yml
View file @
dfe80556
...
...
@@ -25,6 +25,7 @@ jobs:
env
:
TEST_LOCAL
:
1
TEST_PREFERRED_CHAIN
:
(STAGING) Pretend Pear X1
TEST_ACME_Server
:
"
LetsEncrypt.org_test"
steps
:
-
uses
:
actions/checkout@v2
-
name
:
Clone acmetest
...
...
.github/workflows/MacOS.yml
View file @
dfe80556
...
...
@@ -25,11 +25,11 @@ jobs:
CA
:
"
"
CA_EMAIL
:
"
"
TEST_PREFERRED_CHAIN
:
(STAGING) Pretend Pear X1
-
TEST_ACME_Server
:
"
ZeroSSL.com"
CA_ECDSA
:
"
ZeroSSL
ECC
Domain
Secure
Site
CA"
CA
:
"
ZeroSSL
RSA
Domain
Secure
Site
CA"
CA_EMAIL
:
"
githubtest@acme.sh"
TEST_PREFERRED_CHAIN
:
"
"
#
- TEST_ACME_Server: "ZeroSSL.com"
#
CA_ECDSA: "ZeroSSL ECC Domain Secure Site CA"
#
CA: "ZeroSSL RSA Domain Secure Site CA"
#
CA_EMAIL: "githubtest@acme.sh"
#
TEST_PREFERRED_CHAIN: ""
runs-on
:
macos-latest
env
:
TEST_LOCAL
:
1
...
...
.github/workflows/Solaris.yml
View file @
dfe80556
...
...
@@ -25,11 +25,11 @@ jobs:
CA
:
"
"
CA_EMAIL
:
"
"
TEST_PREFERRED_CHAIN
:
(STAGING) Pretend Pear X1
-
TEST_ACME_Server
:
"
ZeroSSL.com"
CA_ECDSA
:
"
ZeroSSL
ECC
Domain
Secure
Site
CA"
CA
:
"
ZeroSSL
RSA
Domain
Secure
Site
CA"
CA_EMAIL
:
"
githubtest@acme.sh"
TEST_PREFERRED_CHAIN
:
"
"
#
- TEST_ACME_Server: "ZeroSSL.com"
#
CA_ECDSA: "ZeroSSL ECC Domain Secure Site CA"
#
CA: "ZeroSSL RSA Domain Secure Site CA"
#
CA_EMAIL: "githubtest@acme.sh"
#
TEST_PREFERRED_CHAIN: ""
runs-on
:
macos-10.15
env
:
TEST_LOCAL
:
1
...
...
.github/workflows/Windows.yml
View file @
dfe80556
...
...
@@ -25,11 +25,11 @@ jobs:
CA
:
"
"
CA_EMAIL
:
"
"
TEST_PREFERRED_CHAIN
:
(STAGING) Pretend Pear X1
-
TEST_ACME_Server
:
"
ZeroSSL.com"
CA_ECDSA
:
"
ZeroSSL
ECC
Domain
Secure
Site
CA"
CA
:
"
ZeroSSL
RSA
Domain
Secure
Site
CA"
CA_EMAIL
:
"
githubtest@acme.sh"
TEST_PREFERRED_CHAIN
:
"
"
#
- TEST_ACME_Server: "ZeroSSL.com"
#
CA_ECDSA: "ZeroSSL ECC Domain Secure Site CA"
#
CA: "ZeroSSL RSA Domain Secure Site CA"
#
CA_EMAIL: "githubtest@acme.sh"
#
TEST_PREFERRED_CHAIN: ""
runs-on
:
windows-latest
env
:
TEST_ACME_Server
:
${{ matrix.TEST_ACME_Server }}
...
...
Dockerfile
View file @
dfe80556
...
...
@@ -65,7 +65,8 @@ RUN for verb in help \
RUN
printf
"%b"
'#!'
"/usr/bin/env sh
\n
\
if [
\"\$
1
\"
=
\"
daemon
\"
]; then
\n
\
trap
\"
echo stop && killall crond && exit 0
\"
SIGTERM SIGINT
\n
\
crond && while true; do sleep 1; done;
\n
\
crond && sleep infinity &
\n
\
wait
\n
\
else
\n
\
exec --
\"\$
@
\"\n
\
fi"
>
/entry.sh
&&
chmod
+x /entry.sh
...
...
README.md
View file @
dfe80556
...
...
@@ -95,6 +95,7 @@ https://github.com/acmesh-official/acmetest
-
Letsencrypt.org CA
-
[
BuyPass.com CA
](
https://github.com/acmesh-official/acme.sh/wiki/BuyPass.com-CA
)
-
[
SSL.com CA
](
https://github.com/acmesh-official/acme.sh/wiki/SSL.com-CA
)
-
[
Google.com Public CA
](
https://github.com/acmesh-official/acme.sh/wiki/Google-Public-CA
)
-
[
Pebble strict Mode
](
https://github.com/letsencrypt/pebble
)
-
Any other
[
RFC8555
](
https://tools.ietf.org/html/rfc8555
)
-compliant CA
...
...
acme.sh
View file @
dfe80556
This diff is collapsed.
Click to expand it.
deploy/mailcow.sh
View file @
dfe80556
...
...
@@ -20,18 +20,23 @@ mailcow_deploy() {
_debug _cca
"
$_cca
"
_debug _cfullchain
"
$_cfullchain
"
_mailcow_path
=
"
${
DEPLOY_MAILCOW_PATH
}
"
_getdeployconf DEPLOY_MAILCOW_PATH
_getdeployconf DEPLOY_MAILCOW_RELOAD
if
[
-z
"
$_mailcow_path
"
]
;
then
_debug DEPLOY_MAILCOW_PATH
"
$DEPLOY_MAILCOW_PATH
"
_debug DEPLOY_MAILCOW_RELOAD
"
$DEPLOY_MAILCOW_RELOAD
"
if
[
-z
"
$DEPLOY_MAILCOW_PATH
"
]
;
then
_err
"Mailcow path is not found, please define DEPLOY_MAILCOW_PATH."
return
1
fi
#Tests if _ssl_path is the mailcow root directory.
if
[
-f
"
${
_mailcow_path
}
/generate_config.sh"
]
;
then
_ssl_path
=
"
${
_mailcow_path
}
/data/assets/ssl/"
else
_ssl_path
=
"
${
_mailcow_path
}
"
_savedeployconf DEPLOY_MAILCOW_PATH
"
$DEPLOY_MAILCOW_PATH
"
[
-n
"
$DEPLOY_MAILCOW_RELOAD
"
]
&&
_savedeployconf DEPLOY_MAILCOW_RELOAD
"
$DEPLOY_MAILCOW_RELOAD
"
_ssl_path
=
"
$DEPLOY_MAILCOW_PATH
"
if
[
-f
"
$DEPLOY_MAILCOW_PATH
/generate_config.sh"
]
;
then
_ssl_path
=
"
$DEPLOY_MAILCOW_PATH
/data/assets/ssl/"
fi
if
[
!
-d
"
$_ssl_path
"
]
;
then
...
...
@@ -40,16 +45,15 @@ mailcow_deploy() {
fi
# ECC or RSA
if
[
-z
"
${
Le_Keylength
}
"
]
;
then
Le_Keylength
=
""
fi
if
_isEccKey
"
${
Le_Keylength
}
"
;
then
length
=
$(
_readdomainconf Le_Keylength
)
if
_isEccKey
"
$length
"
;
then
_info
"ECC key type detected"
_cert_name_prefix
=
"ecdsa-"
else
_info
"RSA key type detected"
_cert_name_prefix
=
""
fi
_info
"Copying key and cert"
_real_key
=
"
$_ssl_path
/
${
_cert_name_prefix
}
key.pem"
if
!
cat
"
$_ckey
"
>
"
$_real_key
"
;
then
...
...
@@ -63,7 +67,7 @@ mailcow_deploy() {
return
1
fi
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
)
"
DEFAULT_MAILCOW_RELOAD
=
"docker restart
\
$
(docker ps -
-quiet --filter name=nginx-mailcow --filter
name=dovecot-mailcow)"
_reload
=
"
${
DEPLOY_MAILCOW_RELOAD
:-
$DEFAULT_MAILCOW_RELOAD
}
"
_info
"Run reload:
$_reload
"
...
...
deploy/qiniu.sh
View file @
dfe80556
...
...
@@ -53,7 +53,7 @@ qiniu_deploy() {
sslcert_access_token
=
"
$(
_make_access_token
"
$sslcert_path
"
)
"
_debug sslcert_access_token
"
$sslcert_access_token
"
export
_H1
=
"Authorization: QBox
$sslcert_access_token
"
sslcert_response
=
$(
_post
"
$sslcerl_body
"
"
$QINIU_API_BASE$sslcert_path
"
0
"POST"
"application/json"
| _dbase64
"multiline"
)
sslcert_response
=
$(
_post
"
$sslcerl_body
"
"
$QINIU_API_BASE$sslcert_path
"
0
"POST"
"application/json"
| _dbase64
)
if
!
_contains
"
$sslcert_response
"
"certID"
;
then
_err
"Error in creating certificate:"
...
...
@@ -75,7 +75,7 @@ qiniu_deploy() {
update_access_token
=
"
$(
_make_access_token
"
$update_path
"
)
"
_debug update_access_token
"
$update_access_token
"
export
_H1
=
"Authorization: QBox
$update_access_token
"
update_response
=
$(
_post
"
$update_body
"
"
$QINIU_API_BASE$update_path
"
0
"PUT"
"application/json"
| _dbase64
"multiline"
)
update_response
=
$(
_post
"
$update_body
"
"
$QINIU_API_BASE$update_path
"
0
"PUT"
"application/json"
| _dbase64
)
if
_contains
"
$update_response
"
"error"
;
then
_err
"Error in updating domain
$domain
httpsconf:"
...
...
deploy/routeros.sh
View file @
dfe80556
...
...
@@ -70,6 +70,7 @@ routeros_deploy() {
_ccert
=
"
$3
"
_cca
=
"
$4
"
_cfullchain
=
"
$5
"
_err_code
=
0
_debug _cdomain
"
$_cdomain
"
_debug _ckey
"
$_ckey
"
...
...
@@ -126,11 +127,17 @@ routeros_deploy() {
_savedeployconf ROUTER_OS_SCP_CMD
"
$ROUTER_OS_SCP_CMD
"
_savedeployconf ROUTER_OS_ADDITIONAL_SERVICES
"
$ROUTER_OS_ADDITIONAL_SERVICES
"
_info
"Trying to push key '
$_ckey
' to router"
$ROUTER_OS_SCP_CMD
"
$_ckey
"
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
.key"
_info
"Trying to push cert '
$_cfullchain
' to router"
$ROUTER_OS_SCP_CMD
"
$_cfullchain
"
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
.cer"
DEPLOY_SCRIPT_CMD
=
"/system script add name=
\"
LE Cert Deploy -
$_cdomain
\"
owner=
$ROUTER_OS_USER
\
# push key to routeros
if
!
_scp_certificate
"
$_ckey
"
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
.key"
;
then
return
$_err_code
fi
# push certificate chain to routeros
if
!
_scp_certificate
"
$_cfullchain
"
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
:
$_cdomain
.cer"
;
then
return
$_err_code
fi
DEPLOY_SCRIPT_CMD
=
"/system script add name=
\"
LE Cert Deploy -
$_cdomain
\"
owner=
$ROUTER_OS_USERNAME
\
comment=
\"
generated by routeros deploy script in acme.sh
\"
\
source=
\"
/certificate remove [ find name=
$_cdomain
.cer_0 ];
\
\n
/certificate remove [ find name=
$_cdomain
.cer_1 ];
\
...
...
@@ -146,12 +153,51 @@ source=\"/certificate remove [ find name=$_cdomain.cer_0 ];\
\n
$ROUTER_OS_ADDITIONAL_SERVICES
;
\
\n\"
"
# shellcheck disable=SC2029
$ROUTER_OS_SSH_CMD
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
"
"
$DEPLOY_SCRIPT_CMD
"
# shellcheck disable=SC2029
$ROUTER_OS_SSH_CMD
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
"
"/system script run
\"
LE Cert Deploy -
$_cdomain
\"
"
# shellcheck disable=SC2029
$ROUTER_OS_SSH_CMD
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
"
"/system script remove
\"
LE Cert Deploy -
$_cdomain
\"
"
if
!
_ssh_remote_cmd
"
$DEPLOY_SCRIPT_CMD
"
;
then
return
$_err_code
fi
if
!
_ssh_remote_cmd
"/system script run
\"
LE Cert Deploy -
$_cdomain
\"
"
;
then
return
$_err_code
fi
if
!
_ssh_remote_cmd
"/system script remove
\"
LE Cert Deploy -
$_cdomain
\"
"
;
then
return
$_err_code
fi
return
0
}
# inspired by deploy/ssh.sh
_ssh_remote_cmd
()
{
_cmd
=
"
$1
"
_secure_debug
"Remote commands to execute:
$_cmd
"
_info
"Submitting sequence of commands to routeros"
# quotations in bash cmd below intended. Squash travis spellcheck error
# shellcheck disable=SC2029
$ROUTER_OS_SSH_CMD
"
$ROUTER_OS_USERNAME
@
$ROUTER_OS_HOST
"
"
$_cmd
"
_err_code
=
"
$?
"
if
[
"
$_err_code
"
!=
"0"
]
;
then
_err
"Error code
$_err_code
returned from routeros"
fi
return
$_err_code
}
_scp_certificate
()
{
_src
=
"
$1
"
_dst
=
"
$2
"
_secure_debug
"scp '
$_src
' to '
$_dst
'"
_info
"Push key '
$_src
' to routeros"
$ROUTER_OS_SCP_CMD
"
$_src
"
"
$_dst
"
_err_code
=
"
$?
"
if
[
"
$_err_code
"
!=
"0"
]
;
then
_err
"Error code
$_err_code
returned from scp"
fi
return
$_err_code
}
deploy/truenas.sh
View file @
dfe80556
...
...
@@ -38,7 +38,7 @@ truenas_deploy() {
_getdeployconf DEPLOY_TRUENAS_APIKEY
if
[
-z
"
$DEPLOY_TRUENAS_APIKEY
"
]
;
then
_err
"TrueNAS A
pi Key is
not found, please
defin
e DEPLOY_TRUENAS_APIKEY."
_err
"TrueNAS A
PI key
not found, please
set th
e DEPLOY_TRUENAS_APIKEY
environment variable
."
return
1
fi
_secure_debug2 DEPLOY_TRUENAS_APIKEY
"
$DEPLOY_TRUENAS_APIKEY
"
...
...
@@ -62,15 +62,14 @@ truenas_deploy() {
_info
"Testing Connection TrueNAS"
_response
=
$(
_get
"
$_api_url
/system/state"
)
_info
"TrueNAS
S
ystem
S
tate:
$_response
."
_info
"TrueNAS
s
ystem
s
tate:
$_response
."
if
[
-z
"
$_response
"
]
;
then
_err
"Unable to authenticate to
$_api_url
."
_err
'Check your Connection and set DEPLOY_TRUENAS_HOSTNAME="192.168.178.x".'
_err
'or'
_err
'set DEPLOY_TRUENAS_HOSTNAME="<truenas_dnsname>".'
_err
'Check your Connection and set DEPLOY_TRUENAS_SCHEME="https".'
_err
"Check your Api Key."
_err
'Check your connection settings are correct, e.g.'
_err
'DEPLOY_TRUENAS_HOSTNAME="192.168.x.y" or DEPLOY_TRUENAS_HOSTNAME="truenas.example.com".'
_err
'DEPLOY_TRUENAS_SCHEME="https" or DEPLOY_TRUENAS_SCHEME="http".'
_err
"Verify your TrueNAS API key is valid and set correctly, e.g. DEPLOY_TRUENAS_APIKEY=xxxx...."
return
1
fi
...
...
@@ -78,7 +77,7 @@ truenas_deploy() {
_savedeployconf DEPLOY_TRUENAS_HOSTNAME
"
$DEPLOY_TRUENAS_HOSTNAME
"
_savedeployconf DEPLOY_TRUENAS_SCHEME
"
$DEPLOY_TRUENAS_SCHEME
"
_info
"Getting active certificate from TrueNAS"
_info
"Getting
current
active certificate from TrueNAS"
_response
=
$(
_get
"
$_api_url
/system/general"
)
_active_cert_id
=
$(
echo
"
$_response
"
|
grep
-B2
'"name":'
|
grep
'id'
|
tr
-d
--
'"id: ,'
)
_active_cert_name
=
$(
echo
"
$_response
"
|
grep
'"name":'
|
sed
-n
's/.*: "\(.\{1,\}\)",$/\1/p'
)
...
...
@@ -88,14 +87,14 @@ truenas_deploy() {
_debug Active_UI_http_redirect
"
$_param_httpsredirect
"
if
[
"
$DEPLOY_TRUENAS_SCHEME
"
=
"http"
]
&&
[
"
$_param_httpsredirect
"
=
"true"
]
;
then
_info
"
http Redirect active
"
_info
"
HTTP->HTTPS redirection is enabled
"
_info
"Setting DEPLOY_TRUENAS_SCHEME to 'https'"
DEPLOY_TRUENAS_SCHEME
=
"https"
_api_url
=
"
$DEPLOY_TRUENAS_SCHEME
://
$DEPLOY_TRUENAS_HOSTNAME
/api/v2.0"
_savedeployconf DEPLOY_TRUENAS_SCHEME
"
$DEPLOY_TRUENAS_SCHEME
"
fi
_info
"Upload new certifi
k
ate to TrueNAS"
_info
"Upload
ing
new certifi
c
ate to TrueNAS"
_certname
=
"Letsencrypt_
$(
_utc_date |
tr
' '
'_'
|
tr
-d
--
':'
)
"
_debug3 _certname
"
$_certname
"
...
...
@@ -104,30 +103,30 @@ truenas_deploy() {
_debug3 _add_cert_result
"
$_add_cert_result
"
_info
"
G
et
t
ing
Certificate list to get new Cert ID
"
_info
"
F
et
ch
ing
list of installed certificates
"
_cert_list
=
$(
_get
"
$_api_url
/system/general/ui_certificate_choices"
)
_cert_id
=
$(
echo
"
$_cert_list
"
|
grep
"
$_certname
"
|
sed
-n
's/.*"\([0-9]\{1,\}\)".*$/\1/p'
)
_debug3 _cert_id
"
$_cert_id
"
_info
"
A
ctivate
C
ertificate ID:
$_cert_id
"
_info
"
Current a
ctivate
c
ertificate ID:
$_cert_id
"
_activateData
=
"{
\"
ui_certificate
\"
:
\"
${
_cert_id
}
\"
}"
_activate_result
=
"
$(
_post
"
$_activateData
"
"
$_api_url
/system/general"
""
"PUT"
"application/json"
)
"
_debug3 _activate_result
"
$_activate_result
"
_info
"Check if WebDAV certificate is the same as the
WEB
UI"
_info
"Check
ing
if WebDAV certificate is the same as the
TrueNAS web
UI"
_webdav_list
=
$(
_get
"
$_api_url
/webdav"
)
_webdav_cert_id
=
$(
echo
"
$_webdav_list
"
|
grep
'"certssl":'
|
tr
-d
--
'"certsl: ,'
)
if
[
"
$_webdav_cert_id
"
=
"
$_active_cert_id
"
]
;
then
_info
"Updat
e
the WebDAV
C
ertificate"
_info
"Updat
ing
the WebDAV
c
ertificate"
_debug _webdav_cert_id
"
$_webdav_cert_id
"
_webdav_data
=
"{
\"
certssl
\"
:
\"
${
_cert_id
}
\"
}"
_activate_webdav_cert
=
"
$(
_post
"
$_webdav_data
"
"
$_api_url
/webdav"
""
"PUT"
"application/json"
)
"
_webdav_new_cert_id
=
$(
echo
"
$_activate_webdav_cert
"
| _json_decode |
sed
-n
's/.*: \([0-9]\{1,\}\)
}$/\1/p'
)
_webdav_new_cert_id
=
$(
echo
"
$_activate_webdav_cert
"
| _json_decode |
grep
'"certssl":'
|
sed
-n
's/.*: \([0-9]\{1,\}\)
,\{0,1\
}$/\1/p'
)
if
[
"
$_webdav_new_cert_id
"
-eq
"
$_cert_id
"
]
;
then
_info
"WebDAV
C
ertificate update successfully"
_info
"WebDAV
c
ertificate update
d
successfully"
else
_err
"Unable to set WebDAV certificate"
_debug3 _activate_webdav_cert
"
$_activate_webdav_cert
"
...
...
@@ -136,21 +135,21 @@ truenas_deploy() {
fi
_debug3 _webdav_new_cert_id
"
$_webdav_new_cert_id
"
else
_info
"WebDAV certificate not
set
or not the same as
W
eb UI"
_info
"WebDAV certificate
is
not
configured
or
is
not the same as
TrueNAS w
eb UI"
fi
_info
"Check if FTP certificate is the same as the
WEB
UI"
_info
"Check
ing
if FTP certificate is the same as the
TrueNAS web
UI"
_ftp_list
=
$(
_get
"
$_api_url
/ftp"
)
_ftp_cert_id
=
$(
echo
"
$_ftp_list
"
|
grep
'"ssltls_certificate":'
|
tr
-d
--
'"certislfa:_ ,'
)
if
[
"
$_ftp_cert_id
"
=
"
$_active_cert_id
"
]
;
then
_info
"Updat
e
the FTP
C
ertificate"
_info
"Updat
ing
the FTP
c
ertificate"
_debug _ftp_cert_id
"
$_ftp_cert_id
"
_ftp_data
=
"{
\"
ssltls_certificate
\"
:
\"
${
_cert_id
}
\"
}"
_activate_ftp_cert
=
"
$(
_post
"
$_ftp_data
"
"
$_api_url
/ftp"
""
"PUT"
"application/json"
)
"
_ftp_new_cert_id
=
$(
echo
"
$_activate_ftp_cert
"
| _json_decode |
sed
-n
's/.*: \([0-9]\{1,\}\)
}$/\1/p'
)
_ftp_new_cert_id
=
$(
echo
"
$_activate_ftp_cert
"
| _json_decode |
grep
'"ssltls_certificate":'
|
sed
-n
's/.*: \([0-9]\{1,\}\)
,\{0,1\
}$/\1/p'
)
if
[
"
$_ftp_new_cert_id
"
-eq
"
$_cert_id
"
]
;
then
_info
"FTP
C
ertificate update successfully"
_info
"FTP
c
ertificate update
d
successfully"
else
_err
"Unable to set FTP certificate"
_debug3 _activate_ftp_cert
"
$_activate_ftp_cert
"
...
...
@@ -159,22 +158,45 @@ truenas_deploy() {
fi
_debug3 _activate_ftp_cert
"
$_activate_ftp_cert
"
else
_info
"FTP certificate not
set
or not the same as
W
eb UI"
_info
"FTP certificate
is
not
configured
or
is
not the same as
TrueNAS w
eb UI"
fi
_info
"Delete old Certificate"
_info
"Checking if S3 certificate is the same as the TrueNAS web UI"
_s3_list
=
$(
_get
"
$_api_url
/s3"
)
_s3_cert_id
=
$(
echo
"
$_s3_list
"
|
grep
'"certificate":'
|
tr
-d
--
'"certifa:_ ,'
)
if
[
"
$_s3_cert_id
"
=
"
$_active_cert_id
"
]
;
then
_info
"Updating the S3 certificate"
_debug _s3_cert_id
"
$_s3_cert_id
"
_s3_data
=
"{
\"
certificate
\"
:
\"
${
_cert_id
}
\"
}"
_activate_s3_cert
=
"
$(
_post
"
$_s3_data
"
"
$_api_url
/s3"
""
"PUT"
"application/json"
)
"
_s3_new_cert_id
=
$(
echo
"
$_activate_s3_cert
"
| _json_decode |
grep
'"certificate":'
|
sed
-n
's/.*: \([0-9]\{1,\}\),\{0,1\}$/\1/p'
)
if
[
"
$_s3_new_cert_id
"
-eq
"
$_cert_id
"
]
;
then
_info
"S3 certificate updated successfully"
else
_err
"Unable to set S3 certificate"
_debug3 _activate_s3_cert
"
$_activate_s3_cert
"
_debug3 _s3_new_cert_id
"
$_s3_new_cert_id
"
return
1
fi
_debug3 _activate_s3_cert
"
$_activate_s3_cert
"
else
_info
"S3 certificate is not configured or is not the same as TrueNAS web UI"
fi
_info
"Deleting old certificate"
_delete_result
=
"
$(
_post
""
"
$_api_url
/certificate/id/
$_active_cert_id
"
""
"DELETE"
"application/json"
)
"
_debug3 _delete_result
"
$_delete_result
"
_info
"Reload
WebUI from
TrueNAS"
_info
"Reload
ing
TrueNAS
web UI
"
_restart_UI
=
$(
_get
"
$_api_url
/system/general/ui_restart"
)
_debug2 _restart_UI
"
$_restart_UI
"
if
[
-n
"
$_add_cert_result
"
]
&&
[
-n
"
$_activate_result
"
]
;
then
return
0
else
_err
"Certupdate was not succesful
l
, please
use
--debug"
_err
"Cert
ificate
update was not succesful, please
try again with
--debug"
return
1
fi
}
dnsapi/dns_1984hosting.sh
View file @
dfe80556
...
...
@@ -42,7 +42,7 @@ dns_1984hosting_add() {
_debug
"Add TXT record
$fulldomain
with value '
$txtvalue
'"
value
=
"
$(
printf
'%s'
"
$txtvalue
"
| _url_encode
)
"
url
=
"https://
management.
1984hosting
.com
/domains/entry/"
url
=
"https://1984
.
hosting/domains/entry/"
postdata
=
"entry=new"
postdata
=
"
$postdata
&type=TXT"
...
...
@@ -95,7 +95,7 @@ dns_1984hosting_rm() {
_debug _domain
"
$_domain
"
_debug
"Delete
$fulldomain
TXT record"
url
=
"https://
management.
1984hosting
.com
/domains"
url
=
"https://1984
.
hosting/domains"
if
!
_get_zone_id
"
$url
"
"
$_domain
"
;
then
_err
"invalid zone"
"
$_domain
"
return
1
...
...
@@ -138,7 +138,7 @@ _1984hosting_login() {
_debug
"Login to 1984Hosting as user
$One984HOSTING_Username
"
username
=
$(
printf
'%s'
"
$One984HOSTING_Username
"
| _url_encode
)
password
=
$(
printf
'%s'
"
$One984HOSTING_Password
"
| _url_encode
)
url
=
"https://
management.
1984hosting
.com
/accounts/checkuserauth/"
url
=
"https://1984
.
hosting/accounts/checkuserauth/"
response
=
"
$(
_post
"username=
$username
&password=
$password
&otpkey="
$url
)
"
response
=
"
$(
echo
"
$response
"
| _normalizeJson
)
"
...
...
@@ -175,7 +175,7 @@ _check_cookies() {
return
1
fi
_authget
"https://
management.
1984hosting
.com
/accounts/loginstatus/"
_authget
"https://1984
.
hosting/accounts/loginstatus/"
if
_contains
"
$response
"
'"ok": true'
;
then
_debug
"Cached cookies still valid"
return
0
...
...
@@ -204,7 +204,7 @@ _get_root() {
return
1
fi
_authget
"https://
management.
1984hosting
.com
/domains/soacheck/?zone=
$h
&nameserver=ns0.1984.is."
_authget
"https://1984
.
hosting/domains/soacheck/?zone=
$h
&nameserver=ns0.1984.is."
if
_contains
"
$_response
"
"serial"
&&
!
_contains
"
$_response
"
"null"
;
then
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
$p
)
_domain
=
"
$h
"
...
...
@@ -251,11 +251,11 @@ _htmlget() {
# add extra headers to request
_authpost
()
{
url
=
"https://
management.
1984hosting
.com
/domains"
url
=
"https://1984
.
hosting/domains"
_get_zone_id
"
$url
"
"
$_domain
"
csrf_header
=
"
$(
echo
"
$One984HOSTING_CSRFTOKEN_COOKIE
"
| _egrep_o
"=[^=][0-9a-zA-Z]*"
|
tr
-d
"="
)
"
export
_H1
=
"Cookie:
$One984HOSTING_CSRFTOKEN_COOKIE
;
$One984HOSTING_SESSIONID_COOKIE
"
export
_H2
=
"Referer: https://
management.
1984hosting
.com
/domains/
$_zone_id
"
export
_H2
=
"Referer: https://1984
.
hosting/domains/
$_zone_id
"
export
_H3
=
"X-CSRFToken:
$csrf_header
"
_response
=
$(
_post
"
$1
"
"
$2
"
)
}
dnsapi/dns_aws.sh
View file @
dfe80556
...
...
@@ -152,34 +152,23 @@ dns_aws_rm() {
_get_root
()
{
domain
=
$1
i
=
2
i
=
1
p
=
1
if
aws_rest GET
"2013-04-01/hostedzone"
;
then
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug2
"Checking domain:
$h
"
if
[
-z
"
$h
"
]
;
then
if
_contains
"
$response
"
"<IsTruncated>true</IsTruncated>"
&&
_contains
"
$response
"
"<NextMarker>"
;
then
_debug
"IsTruncated"
_nextMarker
=
"
$(
echo
"
$response
"
| _egrep_o
"<NextMarker>.*</NextMarker>"
|
cut
-d
'>'
-f
2 |
cut
-d
'<'
-f
1
)
"
_debug
"NextMarker"
"
$_nextMarker
"
if
aws_rest GET
"2013-04-01/hostedzone"
"marker=
$_nextMarker
"
;
then
_debug
"Truncated request OK"
i
=
2
p
=
1
continue
else
_err
"Truncated request error."
fi
fi
#not valid
_err
"Invalid domain"
return
1
fi
# iterate over names (a.b.c.d -> b.c.d -> c.d -> d)
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug
"Checking domain:
$h
"
if
[
-z
"
$h
"
]
;
then
_error
"invalid domain"
return
1
fi
# iterate over paginated result for list_hosted_zones
aws_rest GET
"2013-04-01/hostedzone"
while
true
;
do
if
_contains
"
$response
"
"<Name>
$h
.</Name>"
;
then
hostedzone
=
"
$(
echo
"
$response
"
|
sed
's/<HostedZone>/#&/g'
|
tr
'#'
'\n'
| _egrep_o
"<HostedZone><Id>[^<]*<.Id><Name>
$h
.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>"
)
"
hostedzone
=
"
$(
echo
"
$response
"
|
tr
-d
'\n'
|
sed
's/<HostedZone>/#&/g'
|
tr
'#'
'\n'
| _egrep_o
"<HostedZone><Id>[^<]*<.Id><Name>
$h
.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>"
)
"
_debug hostedzone
"
$hostedzone
"
if
[
"
$hostedzone
"
]
;
then
_domain_id
=
$(
printf
"%s
\n
"
"
$hostedzone
"
| _egrep_o
"<Id>.*<.Id>"
|
head
-n
1 | _egrep_o
">.*<"
|
tr
-d
"<>"
)
...
...
@@ -192,10 +181,19 @@ _get_root() {
return
1
fi
fi
p
=
$i
i
=
$(
_math
"
$i
"
+ 1
)
if
_contains
"
$response
"
"<IsTruncated>true</IsTruncated>"
&&
_contains
"
$response
"
"<NextMarker>"
;
then
_debug
"IsTruncated"
_nextMarker
=
"
$(
echo
"
$response
"
| _egrep_o
"<NextMarker>.*</NextMarker>"
|
cut
-d
'>'
-f
2 |
cut
-d
'<'
-f
1
)
"
_debug
"NextMarker"
"
$_nextMarker
"
else
break
fi
_debug
"Checking domain:
$h
- Next Page "
aws_rest GET
"2013-04-01/hostedzone"
"marker=
$_nextMarker
"
done
fi
p
=
$i
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
}
...
...
dnsapi/dns_cf.sh
View file @
dfe80556
...
...
@@ -32,7 +32,8 @@ dns_cf_add() {
else
_saveaccountconf_mutable CF_Token
"
$CF_Token
"
_saveaccountconf_mutable CF_Account_ID
"
$CF_Account_ID
"
_saveaccountconf_mutable CF_Zone_ID
"
$CF_Zone_ID
"
_clearaccountconf_mutable CF_Zone_ID
_clearaccountconf CF_Zone_ID
fi
else
if
[
-z
"
$CF_Key
"
]
||
[
-z
"
$CF_Email
"
]
;
then
...
...
@@ -51,6 +52,14 @@ dns_cf_add() {
#save the api key and email to the account conf file.
_saveaccountconf_mutable CF_Key
"
$CF_Key
"
_saveaccountconf_mutable CF_Email
"
$CF_Email
"
_clearaccountconf_mutable CF_Token
_clearaccountconf_mutable CF_Account_ID
_clearaccountconf_mutable CF_Zone_ID
_clearaccountconf CF_Token
_clearaccountconf CF_Account_ID
_clearaccountconf CF_Zone_ID
fi
_debug
"First detect the root zone"
...
...
dnsapi/dns_cx.sh
deleted
100755 → 0
View file @
6d2ab4d2
#!/usr/bin/env sh
# CloudXNS Domain api
#
#CX_Key="1234"
#
#CX_Secret="sADDsdasdgdsf"
CX_Api
=
"https://www.cloudxns.net/api2"
#REST_API
######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_cx_add
()
{
fulldomain
=
$1
txtvalue
=
$2
CX_Key
=
"
${
CX_Key
:-
$(
_readaccountconf_mutable CX_Key
)
}
"
CX_Secret
=
"
${
CX_Secret
:-
$(
_readaccountconf_mutable CX_Secret
)
}
"
if
[
-z
"
$CX_Key
"
]
||
[
-z
"
$CX_Secret
"
]
;
then
CX_Key
=
""
CX_Secret
=
""
_err
"You don't specify cloudxns.net api key or secret yet."
_err
"Please create you key and try again."
return
1
fi
REST_API
=
"
$CX_Api
"
#save the api key and email to the account conf file.
_saveaccountconf_mutable CX_Key
"
$CX_Key
"
_saveaccountconf_mutable CX_Secret
"
$CX_Secret
"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
add_record
"
$_domain
"
"
$_sub_domain
"
"
$txtvalue
"
}
#fulldomain txtvalue
dns_cx_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
CX_Key
=
"
${
CX_Key
:-
$(
_readaccountconf_mutable CX_Key
)
}
"
CX_Secret
=
"
${
CX_Secret
:-
$(
_readaccountconf_mutable CX_Secret
)
}
"
REST_API
=
"
$CX_Api
"
if
_get_root
"
$fulldomain
"
;
then
record_id
=
""
existing_records
"
$_domain
"
"
$_sub_domain
"
"
$txtvalue
"
if
[
"
$record_id
"
]
;
then
_rest DELETE
"record/
$record_id
/
$_domain_id
"
"{}"
_info
"Deleted record
${
fulldomain
}
"
fi
fi
}
#usage: root sub
#return if the sub record already exists.
#echos the existing records count.
# '0' means doesn't exist
existing_records
()
{
_debug
"Getting txt records"
root
=
$1
sub
=
$2
if
!
_rest GET
"record/
$_domain_id
?:domain_id?host_id=0&offset=0&row_num=100"
;
then
return
1
fi
seg
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
'"record_id":[^{]*host":"'
"
$_sub_domain
"
'"[^}]*\}'
)
_debug seg
"
$seg
"
if
[
-z
"
$seg
"
]
;
then
return
0
fi
if
printf
"%s"
"
$response
"
|
grep
'"type":"TXT"'
>
/dev/null
;
then
record_id
=
$(
printf
"%s
\n
"
"
$seg
"
| _egrep_o
'"record_id":"[^"]*"'
|
cut
-d
:
-f
2 |
tr
-d
\"
| _head_n 1
)
_debug record_id
"
$record_id
"
return
0
fi
}
#add the txt record.
#usage: root sub txtvalue
add_record
()
{
root
=
$1
sub
=
$2
txtvalue
=
$3
fulldomain
=
"
$sub
.
$root
"
_info
"Adding record"
if
!
_rest POST
"record"
"{
\"
domain_id
\"
:
$_domain_id
,
\"
host
\"
:
\"
$_sub_domain
\"
,
\"
value
\"
:
\"
$txtvalue
\"
,
\"
type
\"
:
\"
TXT
\"
,
\"
ttl
\"
:600,
\"
line_id
\"
:1}"
;
then
return
1
fi
return
0
}
#################### Private functions below ##################################
#_acme-challenge.www.domain.com
#returns
# _sub_domain=_acme-challenge.www
# _domain=domain.com
# _domain_id=sdjkglgdfewsdfg
_get_root
()
{
domain
=
$1
i
=
2
p
=
1
if
!
_rest GET
"domain"
;
then
return
1
fi
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug h
"
$h
"
if
[
-z
"
$h
"
]
;
then
#not valid
return
1
fi
if
_contains
"
$response
"
"
$h
."
;
then
seg
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
'"id":[^{]*"'
"
$h
"
'."[^}]*}'
)
_debug seg
"
$seg
"
_domain_id
=
$(
printf
"%s
\n
"
"
$seg
"
| _egrep_o
"
\"
id
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
)
_debug _domain_id
"
$_domain_id
"
if
[
"
$_domain_id
"
]
;
then
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
$p
)
_debug _sub_domain
"
$_sub_domain
"
_domain
=
"
$h
"
_debug _domain
"
$_domain
"
return
0
fi
return
1
fi
p
=
"
$i
"
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
}
#Usage: method URI data
_rest
()
{
m
=
$1
ep
=
"
$2
"
_debug ep
"
$ep
"
url
=
"
$REST_API
/
$ep
"
_debug url
"
$url
"
cdate
=
$(
date
-u
"+%Y-%m-%d %H:%M:%S UTC"
)
_debug cdate
"
$cdate
"
data
=
"
$3
"
_debug data
"
$data
"
sec
=
"
$CX_Key$url$data$cdate$CX_Secret
"
_debug sec
"
$sec
"
hmac
=
$(
printf
"%s"
"
$sec
"
| _digest md5 hex
)
_debug hmac
"
$hmac
"
export
_H1
=
"API-KEY:
$CX_Key
"
export
_H2
=
"API-REQUEST-DATE:
$cdate
"
export
_H3
=
"API-HMAC:
$hmac
"
export
_H4
=
"Content-Type: application/json"
if
[
"
$data
"
]
;
then
response
=
"
$(
_post
"
$data
"
"
$url
"
""
"
$m
"
)
"
else
response
=
"
$(
_get
"
$url
"
)
"
fi
if
[
"
$?
"
!=
"0"
]
;
then
_err
"error
$ep
"
return
1
fi
_debug2 response
"
$response
"
_contains
"
$response
"
'"code":1'
}
dnsapi/dns_cyon.sh
View file @
dfe80556
...
...
@@ -44,7 +44,7 @@ dns_cyon_rm() {
_cyon_load_credentials
()
{
# Convert loaded password to/from base64 as needed.
if
[
"
${
CY_Password_B64
}
"
]
;
then
CY_Password
=
"
$(
printf
"%s"
"
${
CY_Password_B64
}
"
| _dbase64
"multiline"
)
"
CY_Password
=
"
$(
printf
"%s"
"
${
CY_Password_B64
}
"
| _dbase64
)
"
elif
[
"
${
CY_Password
}
"
]
;
then
CY_Password_B64
=
"
$(
printf
"%s"
"
${
CY_Password
}
"
| _base64
)
"
fi
...
...
dnsapi/dns_edgedns.sh
View file @
dfe80556
...
...
@@ -176,6 +176,7 @@ _EDGEDNS_credentials() {
_debug
"GettingEdge DNS credentials"
_log
"
$(
printf
"ACME DNSAPI Edge DNS version %s"
${
ACME_EDGEDNS_VERSION
}
)
"
args_missing
=
0
AKAMAI_ACCESS_TOKEN
=
"
${
AKAMAI_ACCESS_TOKEN
:-
$(
_readaccountconf_mutable AKAMAI_ACCESS_TOKEN
)
}
"
if
[
-z
"
$AKAMAI_ACCESS_TOKEN
"
]
;
then
AKAMAI_ACCESS_TOKEN
=
""
AKAMAI_CLIENT_TOKEN
=
""
...
...
@@ -184,6 +185,7 @@ _EDGEDNS_credentials() {
_err
"AKAMAI_ACCESS_TOKEN is missing"
args_missing
=
1
fi
AKAMAI_CLIENT_TOKEN
=
"
${
AKAMAI_CLIENT_TOKEN
:-
$(
_readaccountconf_mutable AKAMAI_CLIENT_TOKEN
)
}
"
if
[
-z
"
$AKAMAI_CLIENT_TOKEN
"
]
;
then
AKAMAI_ACCESS_TOKEN
=
""
AKAMAI_CLIENT_TOKEN
=
""
...
...
@@ -192,6 +194,7 @@ _EDGEDNS_credentials() {
_err
"AKAMAI_CLIENT_TOKEN is missing"
args_missing
=
1
fi
AKAMAI_HOST
=
"
${
AKAMAI_HOST
:-
$(
_readaccountconf_mutable AKAMAI_HOST
)
}
"
if
[
-z
"
$AKAMAI_HOST
"
]
;
then
AKAMAI_ACCESS_TOKEN
=
""
AKAMAI_CLIENT_TOKEN
=
""
...
...
@@ -200,6 +203,7 @@ _EDGEDNS_credentials() {
_err
"AKAMAI_HOST is missing"
args_missing
=
1
fi
AKAMAI_CLIENT_SECRET
=
"
${
AKAMAI_CLIENT_SECRET
:-
$(
_readaccountconf_mutable AKAMAI_CLIENT_SECRET
)
}
"
if
[
-z
"
$AKAMAI_CLIENT_SECRET
"
]
;
then
AKAMAI_ACCESS_TOKEN
=
""
AKAMAI_CLIENT_TOKEN
=
""
...
...
dnsapi/dns_fornex.sh
0 → 100644
View file @
dfe80556
#!/usr/bin/env sh
#Author: Timur Umarov <inbox@tumarov.com>
FORNEX_API_URL
=
"https://fornex.com/api/dns/v0.1"
######## Public functions #####################
#Usage: dns_fornex_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_fornex_add
()
{
fulldomain
=
$1
txtvalue
=
$2
if
!
_Fornex_API
;
then
return
1
fi
if
!
_get_root
"
$fulldomain
"
;
then
_err
"Unable to determine root domain"
return
1
else
_debug _domain
"
$_domain
"
fi
_info
"Adding record"
if
_rest POST
"
$_domain
/entry_set/add/"
"host=
$fulldomain
&type=TXT&value=
$txtvalue
&apikey=
$FORNEX_API_KEY
"
;
then
_debug _response
"
$response
"
if
_contains
"
$response
"
'"ok": true'
||
_contains
"
$response
"
'Такая запись уже существует.'
;
then
_info
"Added, OK"
return
0
fi
fi
_err
"Add txt record error."
return
1
}
#Usage: dns_fornex_rm _acme-challenge.www.domain.com
dns_fornex_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
if
!
_Fornex_API
;
then
return
1
fi
if
!
_get_root
"
$fulldomain
"
;
then
_err
"Unable to determine root domain"
return
1
else
_debug _domain
"
$_domain
"
fi
_debug
"Getting txt records"
_rest GET
"
$_domain
/entry_set.json?apikey=
$FORNEX_API_KEY
"
if
!
_contains
"
$response
"
"
$txtvalue
"
;
then
_err
"Txt record not found"
return
1
fi
_record_id
=
"
$(
echo
"
$response
"
| _egrep_o
"{[^{]*
\"
value
\"
*:*
\"
$txtvalue
\"
[^}]*}"
|
sed
-n
-e
's#.*"id": \([0-9]*\).*#\1#p'
)
"
_debug
"_record_id"
"
$_record_id
"
if
[
-z
"
$_record_id
"
]
;
then
_err
"can not find _record_id"
return
1
fi
if
!
_rest POST
"
$_domain
/entry_set/
$_record_id
/delete/"
"apikey=
$FORNEX_API_KEY
"
;
then
_err
"Delete record error."
return
1
fi
return
0
}
#################### Private functions below ##################################
#_acme-challenge.www.domain.com
#returns
# _sub_domain=_acme-challenge.www
# _domain=domain.com
_get_root
()
{
domain
=
$1
i
=
1
while
true
;
do
h
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug h
"
$h
"
if
[
-z
"
$h
"
]
;
then
#not valid
return
1
fi
if
!
_rest GET
"domain_list.json?q=
$h
&apikey=
$FORNEX_API_KEY
"
;
then
return
1
fi
if
_contains
"
$response
"
"
\"
$h
\"
"
>
/dev/null
;
then
_domain
=
$h
return
0
else
_debug
"
$h
not found"
fi
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
}
_Fornex_API
()
{
FORNEX_API_KEY
=
"
${
FORNEX_API_KEY
:-
$(
_readaccountconf_mutable FORNEX_API_KEY
)
}
"
if
[
-z
"
$FORNEX_API_KEY
"
]
;
then
FORNEX_API_KEY
=
""
_err
"You didn't specify the Fornex API key yet."
_err
"Please create your key and try again."
return
1
fi
_saveaccountconf_mutable FORNEX_API_KEY
"
$FORNEX_API_KEY
"
}
#method method action data
_rest
()
{
m
=
$1
ep
=
"
$2
"
data
=
"
$3
"
_debug
"
$ep
"
export
_H1
=
"Accept: application/json"
if
[
"
$m
"
!=
"GET"
]
;
then
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$FORNEX_API_URL
/
$ep
"
""
"
$m
"
)
"
else
response
=
"
$(
_get
"
$FORNEX_API_URL
/
$ep
"
| _normalizeJson
)
"
fi
_ret
=
"
$?
"
if
[
"
$_ret
"
!=
"0"
]
;
then
_err
"error
$ep
"
return
1
fi
_debug2 response
"
$response
"
return
0
}
Prev
1
2
Next
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