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
446388e0
Unverified
Commit
446388e0
authored
Apr 01, 2018
by
neil
Committed by
GitHub
Apr 01, 2018
Browse files
Merge pull request #1378 from ivarmedi/master
Add dns_loopia
parents
e1628bcd
b7d573a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
446388e0
...
@@ -317,7 +317,7 @@ You don't have to do anything manually!
...
@@ -317,7 +317,7 @@ You don't have to do anything manually!
1.
DirectAdmin API
1.
DirectAdmin API
1.
KingHost (https://www.kinghost.com.br/)
1.
KingHost (https://www.kinghost.com.br/)
1.
Zilore (https://zilore.com)
1.
Zilore (https://zilore.com)
1.
Loopia.se API
And:
And:
...
...
dnsapi/README.md
View file @
446388e0
...
@@ -814,6 +814,28 @@ acme.sh --issue --dns dns_zilore -d example.com -d *.example.com
...
@@ -814,6 +814,28 @@ acme.sh --issue --dns dns_zilore -d example.com -d *.example.com
The
`Zilore_Key`
will be saved in
`~/.acme.sh/account.conf`
and will be reused when needed.
The
`Zilore_Key`
will be saved in
`~/.acme.sh/account.conf`
and will be reused when needed.
## 44. Use Loopia.se API
User must provide login credentials to the Loopia API.
The user needs the following permissions:
-
addSubdomain
-
updateZoneRecord
-
getDomains
-
removeSubdomain
Set the login credentials:
```
export LOOPIA_User="user@loopiaapi"
export LOOPIA_Password="password"
```
And to issue a cert:
```
acme.sh --issue --dns dns_loopia -d example.com -d *.example.com
```
The username and password will be saved in
`~/.acme.sh/account.conf`
and will be reused when needed.
# Use custom API
# Use custom API
If your API is not supported yet, you can write your own DNS API.
If your API is not supported yet, you can write your own DNS API.
...
...
dnsapi/dns_loopia.sh
0 → 100644
View file @
446388e0
#!/usr/bin/env sh
#
#LOOPIA_User="username"
#
#LOOPIA_Password="password"
LOOPIA_Api
=
"https://api.loopia.se/RPCSERV"
######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_loopia_add
()
{
fulldomain
=
$1
txtvalue
=
$2
LOOPIA_User
=
"
${
LOOPIA_User
:-
$(
_readaccountconf_mutable LOOPIA_User
)
}
"
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
fi
#save the api key and email to the account conf file.
_saveaccountconf_mutable LOOPIA_User
"
$LOOPIA_User
"
_saveaccountconf_mutable LOOPIA_Password
"
$LOOPIA_Password
"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
_debug _sub_domain
"
$_sub_domain
"
_debug _domain
"
$_domain
"
_info
"Adding record"
_loopia_add_record
"
$_domain
"
"
$_sub_domain
"
_loopia_update_record
"
$_domain
"
"
$_sub_domain
"
"
$txtvalue
"
}
dns_loopia_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
LOOPIA_User
=
"
${
LOOPIA_User
:-
$(
_readaccountconf_mutable LOOPIA_User
)
}
"
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
fi
#save the api key and email to the account conf file.
_saveaccountconf_mutable LOOPIA_User
"
$LOOPIA_User
"
_saveaccountconf_mutable LOOPIA_Password
"
$LOOPIA_Password
"
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
xml_content
=
$(
printf
'<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>removeSubdomain</methodName>
<params>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
</params>
</methodCall>'
$LOOPIA_User
$LOOPIA_Password
"
$_domain
"
"
$_sub_domain
"
)
response
=
"
$(
_post
"
$xml_content
"
"
$LOOPIA_Api
"
""
"POST"
)
"
if
!
_contains
"
$response
"
"OK"
;
then
_err
"Error could not get txt records"
return
1
fi
}
#################### Private functions below ##################################
_get_root
()
{
domain
=
$1
_debug
"get root"
domain
=
$1
i
=
2
p
=
1
xml_content
=
$(
printf
'<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>getDomains</methodName>
<params>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
</params>
</methodCall>'
$LOOPIA_User
$LOOPIA_Password
)
response
=
"
$(
_post
"
$xml_content
"
"
$LOOPIA_Api
"
""
"POST"
)
"
while
true
;
do
h
=
$(
echo
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
if
[
-z
"
$h
"
]
;
then
#not valid
return
1
fi
if
_contains
"
$response
"
"
$h
"
;
then
_sub_domain
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
$p
)
_domain
=
"
$h
"
return
0
fi
p
=
$i
i
=
$(
_math
"
$i
"
+ 1
)
done
return
1
}
_loopia_update_record
()
{
domain
=
$1
sub_domain
=
$2
txtval
=
$3
xml_content
=
$(
printf
'<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>updateZoneRecord</methodName>
<params>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<struct>
<member>
<name>type</name>
<value><string>TXT</string></value>
</member>
<member>
<name>priority</name>
<value><int>0</int></value>
</member>
<member>
<name>ttl</name>
<value><int>60</int></value>
</member>
<member>
<name>rdata</name>
<value><string>%s</string></value>
</member>
<member>
<name>record_id</name>
<value><int>0</int></value>
</member>
</struct>
</param>
</params>
</methodCall>'
$LOOPIA_User
$LOOPIA_Password
"
$domain
"
"
$sub_domain
"
"
$txtval
"
)
response
=
"
$(
_post
"
$xml_content
"
"
$LOOPIA_Api
"
""
"POST"
)
"
if
!
_contains
"
$response
"
"OK"
;
then
_err
"Error"
return
1
fi
return
0
}
_loopia_add_record
()
{
domain
=
$1
sub_domain
=
$2
xml_content
=
$(
printf
'<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>addSubdomain</methodName>
<params>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
<param>
<value><string>%s</string></value>
</param>
</params>
</methodCall>'
$LOOPIA_User
$LOOPIA_Password
"
$domain
"
"
$sub_domain
"
)
response
=
"
$(
_post
"
$xml_content
"
"
$LOOPIA_Api
"
""
"POST"
)
"
if
!
_contains
"
$response
"
"OK"
;
then
_err
"Error"
return
1
fi
return
0
}
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