Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
218dc339
Commit
218dc339
authored
May 08, 2016
by
neil
Browse files
support lexicon dns api
parent
6626371d
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_lexicon.sh
0 → 100644
View file @
218dc339
#!/usr/bin/env sh
# dns api wrapper of lexicon for acme.sh
lexicon_url
=
"https://github.com/AnalogJ/lexicon"
lexicon_cmd
=
"lexicon"
wiki
=
"https://github.com/Neilpang/acme.sh/wiki/How-to-use-lexicon-dns-api"
######## Public functions #####################
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_lexicon_add
()
{
fulldomain
=
$1
txtvalue
=
$2
domain
=
$(
printf
"
$fulldomain
"
|
cut
-d
.
-f
2-999
)
if
!
_exists
$lexicon_cmd
;
then
_err
"Please install
$lexicon_cmd
first:
$wiki
"
return
1
fi
if
[
-z
"
$PROVIDER
"
]
;
then
_err
"Please define env PROVIDER first:
$wiki
"
return
1
fi
_savedomainconf PROVIDER
"
$PROVIDER
"
export
PROVIDER
Lx_name
=
$(
echo
LEXICON_
${
PROVIDER
}
_USERNAME |
tr
[
a-z]
[
A-Z]
)
eval
Lx_name_v
=
"
\$
$Lx_name
"
_debug
"
$Lx_name
"
"
$Lx_name_v
"
if
[
"
$Lx_name_v
"
]
;
then
_saveaccountconf
$Lx_name
"
$Lx_name_v
"
export
"
$Lx_name
"
fi
Lx_token
=
$(
echo
LEXICON_
${
PROVIDER
}
_TOKEN |
tr
[
a-z]
[
A-Z]
)
eval
Lx_token_v
=
"
\$
$Lx_token
"
_debug
"
$Lx_token
"
"
$Lx_token_v
"
if
[
"
$Lx_token_v
"
]
;
then
_saveaccountconf
$Lx_token
"
$Lx_token_v
"
export
"
$Lx_token
"
fi
Lx_password
=
$(
echo
LEXICON_
${
PROVIDER
}
_PASSWORD |
tr
[
a-z]
[
A-Z]
)
eval
Lx_password_v
=
"
\$
$Lx_password
"
_debug
"
$Lx_password
"
"
$Lx_password_v
"
if
[
"
$Lx_password_v
"
]
;
then
_saveaccountconf
$Lx_password
"
$Lx_password_v
"
export
"
$Lx_password
"
fi
Lx_domaintoken
=
$(
echo
LEXICON_
${
PROVIDER
}
_DOMAINTOKEN |
tr
[
a-z]
[
A-Z]
)
eval
Lx_domaintoken_v
=
"
\$
$Lx_domaintoken
"
_debug
"
$Lx_domaintoken
"
"
$Lx_domaintoken_v
"
if
[
"
$Lx_domaintoken_v
"
]
;
then
export
"
$Lx_domaintoken
"
_saveaccountconf
$Lx_domaintoken
"
$Lx_domaintoken_v
"
fi
$lexicon_cmd
"
$PROVIDER
"
create
${
domain
}
TXT
--name
=
"_acme-challenge.
${
domain
}
."
--content
=
"
${
txtvalue
}
"
}
#################### Private functions bellow ##################################
_info
()
{
if
[[
-z
"
$2
"
]]
;
then
echo
"[
$(
date
)
]
$1
"
else
echo
"[
$(
date
)
]
$1
"
=
"'
$2
'"
fi
}
_err
()
{
_info
"
$@
"
>
&2
return
1
}
_debug
()
{
if
[[
-z
"
$DEBUG
"
]]
;
then
return
fi
_err
"
$@
"
return
0
}
_debug2
()
{
if
[[
"
$DEBUG
"
-ge
"2"
]]
;
then
_debug
"
$@
"
fi
return
}
#################### Private functions bellow ##################################
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