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
f61f2d6e
Commit
f61f2d6e
authored
Mar 21, 2020
by
ThiloGa
Browse files
adaptations to the new api functions
_get_root fully functional due to the extended api
parent
3c79bb77
Changes
1
Show whitespace changes
Inline
Side-by-side
dnsapi/dns_nm.sh
View file @
f61f2d6e
...
...
@@ -6,7 +6,7 @@
# Environment variables:
#
# - $NM_user (your namemaster.de API username)
# - $NM_
md5
(your namemaster.de API password_as_
md5
hash)
# - $NM_
sha256
(your namemaster.de API password_as_
sha256
hash)
#
# Author: Thilo Gass <thilo.gass@gmail.com>
# Git repo: https://github.com/ThiloGa/acme.sh
...
...
@@ -14,42 +14,53 @@
#-- dns_nm_add() - Add TXT record --------------------------------------
# Usage: dns_nm_add _acme-challenge.subdomain.domain.com "XyZ123..."
namemaster_api
=
"https://namemaster.de/api/api.php"
dns_nm_add
()
{
fulldomain
=
$1
txt_value
=
$2
_info
"Using DNS-01 namemaster hook"
NM_user
=
"
${
NM_user
:-
$(
_readaccountconf_mutable NM_user
)
}
"
NM_
md5
=
"
${
NM_
md5
:-
$(
_readaccountconf_mutable NM_
md5
)
}
"
if
[
-z
"
$NM_user
"
]
||
[
-z
"
$NM_
md5
"
]
;
then
NM_
sha256
=
"
${
NM_
sha256
:-
$(
_readaccountconf_mutable NM_
sha256
)
}
"
if
[
-z
"
$NM_user
"
]
||
[
-z
"
$NM_
sha256
"
]
;
then
NM_user
=
""
NM_
md5
=
""
_err
"No auth details provided. Please set user credentials using the
\$
NM_user and
\$
NM_
md5
environment variables."
NM_
sha256
=
""
_err
"No auth details provided. Please set user credentials using the
\$
NM_user and
\$
NM_
sha256
environment variables."
return
1
fi
#save the api user and
md5
password to the account conf file.
#save the api user and
sha256
password to the account conf file.
_debug
"Save user and hash"
_saveaccountconf_mutable NM_user
"
$NM_user
"
_saveaccountconf_mutable NM_
md5
"
$NM_md5
"
_saveaccountconf_mutable NM_
sha256
"
$NM_sha256
"
zone
=
"
$(
echo
"
$fulldomain
"
| _egrep_o
"[^.]+.[^.]+$"
)
"
get
=
"https://namemaster.de/api/api.php?User=
$NM_user
&Password=
$NM_md5
&Antwort=csv&Int=0&Typ=ACME&Zone=
$zone
&hostname=
$fulldomain
&TXT=
$txt_value
&Action=Auto&Lifetime=3600"
if
!
erg
=
"
$(
_get
"
$get
"
)
"
;
then
_err
"error Deleting
$zone
TXT:
$txt_value
"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
"
$fulldomain
"
return
1
fi
_info
"die Zone lautet:"
"
$zone
"
get
=
"
$namemaster_api
?User=
$NM_user
&Password=
$NM_sha256
&Antwort=csv&Typ=ACME&zone=
$zone
&hostname=
$fulldomain
&TXT=
$txt_value
&Action=Auto&Lifetime=3600"
if
!
erg
=
"
$(
_get
"
$get
"
)
"
then
_err
"error Adding
$fulldomain
TXT:
$txt_value
"
return
1
fi
if
_contains
"
$erg
"
"Success"
;
then
_info
"Success, TXT Added, OK"
else
_err
"error Adding
$
zone
TXT:
$txt_value
erg:
$erg
"
_err
"error Adding
$
fulldomain
TXT:
$txt_value
erg:
$erg
"
return
1
fi
_debug
"ok Auto
$
zone
TXT:
$txt_value
erg:
$erg
"
_debug
"ok Auto
$
fulldomain
TXT:
$txt_value
erg:
$erg
"
return
0
}
dns_nm_rm
()
{
...
...
@@ -58,30 +69,52 @@ dns_nm_rm() {
txt_value
=
$2
NM_user
=
"
${
NM_user
:-
$(
_readaccountconf_mutable NM_user
)
}
"
NM_
md5
=
"
${
NM_
md5
:-
$(
_readaccountconf_mutable NM_
md5
)
}
"
if
[
-z
"
$NM_user
"
]
||
[
-z
"
$NM_
md5
"
]
;
then
NM_
sha256
=
"
${
NM_
sha256
:-
$(
_readaccountconf_mutable NM_
sha256
)
}
"
if
[
-z
"
$NM_user
"
]
||
[
-z
"
$NM_
sha256
"
]
;
then
NM_user
=
""
NM_
md5
=
""
_err
"No auth details provided. Please set user credentials using the
\$
NM_user and
\$
NM_
md5
environment variables."
NM_
sha256
=
""
_err
"No auth details provided. Please set user credentials using the
\$
NM_user and
\$
NM_
sha256
environment variables."
return
1
fi
zone
=
"
$(
echo
"
$fulldomain
"
| _egrep_o
"[^.]+.[^.]+$"
)
"
get
=
"
https://
namemaster
.de/api/api.php
?User=
$NM_user
&Password=
$NM_
md5
&Antwort=csv&
Int=0&
Typ=TXT&Zone=
$zone
&hostname=
$fulldomain
&TXT=
$txt_value
&Action=Delete_IN
&TTL=0
"
get
=
"
$
namemaster
_api
?User=
$NM_user
&Password=
$NM_
sha256
&Antwort=csv&Typ=TXT&Zone=
$zone
&hostname=
$fulldomain
&TXT=
$txt_value
&Action=Delete_IN"
if
!
erg
=
"
$(
_get
"
$get
"
)
"
;
then
_err
"error Deleting
$zone
TXT:
$txt_value
"
if
!
erg
=
"
$(
_get
"
$get
"
)
"
then
_err
"error Deleting
$fulldomain
TXT:
$txt_value
"
return
1
fi
if
_contains
"
$erg
"
"Success"
;
then
_info
"Success, TXT removed, OK"
else
_err
"error Auto
$
zone
TXT:
$txt_value
erg:
$erg
"
_err
"error Auto
$
fulldomain
TXT:
$txt_value
erg:
$erg
"
return
1
fi
_debug
"ok Auto
$
zone
TXT:
$txt_value
erg:
$erg
"
_debug
"ok Auto
$
fulldomain
TXT:
$txt_value
erg:
$erg
"
return
0
}
_get_root
()
{
domain
=
$1
get
=
"
$namemaster_api
?User=
$NM_user
&Password=
$NM_sha256
&Typ=acme&hostname=
$domain
&Action=getzone&antwort=csv"
if
!
zone
=
"
$(
_get
"
$get
"
)
"
then
_err
"error getting Zone"
return
1
else
if
_contains
"
$zone
"
"hostname not found"
then
return
1
fi
fi
}
\ No newline at end of file
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