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
d2d023cc
Commit
d2d023cc
authored
Oct 03, 2021
by
Bjarne Saltbaek
Browse files
added saving of cPanel_Hostname
parent
7f9b8d68
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_cpanel.sh
View file @
d2d023cc
#!/bin/bash
#!/usr/bin/env sh
#
#Author: Bjarne Saltbaek
#Report Bugs here: https://github.com/acmesh-official/acme.sh
#Report Bugs here: https://github.com/acmesh-official/acme.sh
/issues/3732
#
#
######## Public functions #####################
...
...
@@ -10,8 +11,11 @@
# cPanel_Username=username
# cPanel_Apitoken=apitoken
# cPanel_Hostname=hostname
#
# Note: the program 'jq' must be availble on your system
#Usage: dns_cpanel_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
# Used to add txt record
dns_cpanel_add
()
{
fulldomain
=
$1
txtvalue
=
$2
...
...
@@ -26,7 +30,7 @@ dns_cpanel_add() {
fi
_debug
"First detect the root zone"
if
!
_get_
domain
"
$fulldomain
"
;
then
if
!
_get_
root
"
$fulldomain
"
;
then
_err
"No matching root domain for
$fulldomain
found"
return
1
fi
...
...
@@ -40,8 +44,8 @@ dns_cpanel_add() {
return
1
}
#Usage: fulldomain txtvalue
#
R
emove the txt record after validation
.
#
Usage: fulldomain txtvalue
#
Used to r
emove the txt record after validation
dns_cpanel_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
...
...
@@ -55,7 +59,7 @@ dns_cpanel_rm() {
return
1
fi
if
!
_get_
domain
;
then
if
!
_get_
root
;
then
_err
"No matching root domain for
$fulldomain
found"
return
1
fi
...
...
@@ -79,17 +83,20 @@ dns_cpanel_rm() {
_checkcredentials
()
{
cPanel_Username
=
"
${
cPanel_Username
:-
$(
_readaccountconf_mutable cPanel_Username
)
}
"
cPanel_Apitoken
=
"
${
cPanel_Apitoken
:-
$(
_readaccountconf_mutable cPanel_Apitoken
)
}
"
cPanel_Hostname
=
"
${
cPanel_Hostname
:-
$(
_readaccountconf_mutable cPanel_Hostname
)
}
"
if
[
-z
"
$cPanel_Username
"
]
||
[
-z
"
$cPanel_Apitoken
"
]
;
then
if
[
-z
"
$cPanel_Username
"
]
||
[
-z
"
$cPanel_Apitoken
"
]
||
[
-z
"
$cPanel_Hostname
"
]
;
then
cPanel_Username
=
""
cPanel_Apitoken
=
""
_err
"You haven't specified cPanel username and apitoken yet."
cPanel_Hostname
=
""
_err
"You haven't specified cPanel username, apitoken and hostname yet."
_err
"Please add credentials and try again."
return
1
fi
#save the credentials to the account conf file.
_saveaccountconf_mutable cPanel_Username
"
$cPanel_Username
"
_saveaccountconf_mutable cPanel_Apitoken
"
$cPanel_Apitoken
"
_saveaccountconf_mutable cPanel_Hostname
"
$cPanel_Hostname
"
return
0
}
...
...
@@ -109,7 +116,7 @@ _myget() {
_result
=
$(
_get
"
$cPanel_Hostname
/
$1
"
)
}
_get_
domain
()
{
_get_
root
()
{
_myget
'json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzones'
_domains
=
$(
echo
"
$_result
"
| jq
'.cpanelresult.data[]| {zones}| .zones| keys'
|
sed
-e
's/"//g'
-e
's/,//g'
-e
's/\[//g'
-e
's/\]//g'
-e
'/^$/d'
-e
's/[[:space:]]//g'
)
_debug
"_result is:
$_result
"
...
...
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