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
1dc420ce
Unverified
Commit
1dc420ce
authored
Apr 25, 2019
by
neil
Committed by
GitHub
Apr 25, 2019
Browse files
Merge pull request #2139 from loonies/dns-loopia-api-endpoint
Make the Loopia API endpoint configurable
parents
e6df1828
aec9c3c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_loopia.sh
View file @
1dc420ce
...
@@ -4,8 +4,10 @@
...
@@ -4,8 +4,10 @@
#LOOPIA_User="username"
#LOOPIA_User="username"
#
#
#LOOPIA_Password="password"
#LOOPIA_Password="password"
#
#LOOPIA_Api="https://api.loopia.<TLD>/RPCSERV"
LOOPIA_Api
=
"https://api.loopia.se/RPCSERV"
LOOPIA_Api
_Default
=
"https://api.loopia.se/RPCSERV"
######## Public functions #####################
######## Public functions #####################
...
@@ -14,19 +16,11 @@ dns_loopia_add() {
...
@@ -14,19 +16,11 @@ dns_loopia_add() {
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
LOOPIA_User
=
"
${
LOOPIA_User
:-
$(
_readaccountconf_mutable LOOPIA_User
)
}
"
if
!
_loopia_load_config
;
then
LOOPIA_Password
=
"
${
LOOPIA_Password
:-
$(
_readaccountconf_mutable LOOPIA_Password
)
}
"
if
[
-z
"
$LOOPIA_User
"
]
||
[
-z
"
$LOOPIA_Password
"
]
;
then
LOOPIA_User
=
""
LOOPIA_Password
=
""
_err
"You don't specify loopia user and password yet."
_err
"Please create you key and try again."
return
1
return
1
fi
fi
#save the api key and email to the account conf file.
_loopia_save_config
_saveaccountconf_mutable LOOPIA_User
"
$LOOPIA_User
"
_saveaccountconf_mutable LOOPIA_Password
"
$LOOPIA_Password
"
_debug
"First detect the root zone"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
if
!
_get_root
"
$fulldomain
"
;
then
...
@@ -47,19 +41,11 @@ dns_loopia_rm() {
...
@@ -47,19 +41,11 @@ dns_loopia_rm() {
fulldomain
=
$1
fulldomain
=
$1
txtvalue
=
$2
txtvalue
=
$2
LOOPIA_User
=
"
${
LOOPIA_User
:-
$(
_readaccountconf_mutable LOOPIA_User
)
}
"
if
!
_loopia_load_config
;
then
LOOPIA_Password
=
"
${
LOOPIA_Password
:-
$(
_readaccountconf_mutable LOOPIA_Password
)
}
"
if
[
-z
"
$LOOPIA_User
"
]
||
[
-z
"
$LOOPIA_Password
"
]
;
then
LOOPIA_User
=
""
LOOPIA_Password
=
""
_err
"You don't specify LOOPIA user and password yet."
_err
"Please create you key and try again."
return
1
return
1
fi
fi
#save the api key and email to the account conf file.
_loopia_save_config
_saveaccountconf_mutable LOOPIA_User
"
$LOOPIA_User
"
_saveaccountconf_mutable LOOPIA_Password
"
$LOOPIA_Password
"
_debug
"First detect the root zone"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
if
!
_get_root
"
$fulldomain
"
;
then
...
@@ -84,7 +70,7 @@ dns_loopia_rm() {
...
@@ -84,7 +70,7 @@ dns_loopia_rm() {
<value><string>%s</string></value>
<value><string>%s</string></value>
</param>
</param>
</params>
</params>
</methodCall>'
$LOOPIA_User
$LOOPIA_Password
"
$_domain
"
"
$_sub_domain
"
)
</methodCall>'
"
$LOOPIA_User
"
"
$LOOPIA_Password
"
"
$_domain
"
"
$_sub_domain
"
)
response
=
"
$(
_post
"
$xml_content
"
"
$LOOPIA_Api
"
""
"POST"
)
"
response
=
"
$(
_post
"
$xml_content
"
"
$LOOPIA_Api
"
""
"POST"
)
"
...
@@ -96,6 +82,36 @@ dns_loopia_rm() {
...
@@ -96,6 +82,36 @@ dns_loopia_rm() {
#################### Private functions below ##################################
#################### Private functions below ##################################
_loopia_load_config
()
{
LOOPIA_Api
=
"
${
LOOPIA_Api
:-
$(
_readaccountconf_mutable LOOPIA_Api
)
}
"
LOOPIA_User
=
"
${
LOOPIA_User
:-
$(
_readaccountconf_mutable LOOPIA_User
)
}
"
LOOPIA_Password
=
"
${
LOOPIA_Password
:-
$(
_readaccountconf_mutable LOOPIA_Password
)
}
"
if
[
-z
"
$LOOPIA_Api
"
]
;
then
LOOPIA_Api
=
"
$LOOPIA_Api_Default
"
fi
if
[
-z
"
$LOOPIA_User
"
]
||
[
-z
"
$LOOPIA_Password
"
]
;
then
LOOPIA_User
=
""
LOOPIA_Password
=
""
_err
"A valid Loopia API user and password not provided."
_err
"Please provide a valid API user and try again."
return
1
fi
return
0
}
_loopia_save_config
()
{
if
[
"
$LOOPIA_Api
"
!=
"
$LOOPIA_Api_Default
"
]
;
then
_saveaccountconf_mutable LOOPIA_Api
"
$LOOPIA_Api
"
fi
_saveaccountconf_mutable LOOPIA_User
"
$LOOPIA_User
"
_saveaccountconf_mutable LOOPIA_Password
"
$LOOPIA_Password
"
}
_loopia_get_records
()
{
_loopia_get_records
()
{
domain
=
$1
domain
=
$1
sub_domain
=
$2
sub_domain
=
$2
...
...
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