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
4d2a0697
Commit
4d2a0697
authored
Mar 26, 2018
by
Felipe Braz
Browse files
fix identation dnsapi/dns_kinghost.sh
parent
c6023782
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
4d2a0697
.idea
ae.sh
dnsapi/dns_kinghost.sh
View file @
4d2a0697
...
...
@@ -17,79 +17,79 @@ KING_Api="https://api.kinghost.net/acme"
# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
# Used to add txt record
dns_kinghost_add
()
{
fulldomain
=
$1
txtvalue
=
$2
KINGHOST_Username
=
"
${
KINGHOST_Username
:-
$(
_readaccountconf_mutable KINGHOST_Username
)
}
"
KINGHOST_Password
=
"
${
KINGHOST_Password
:-
$(
_readaccountconf_mutable KINGHOST_Password
)
}
"
if
[
-z
"
$KINGHOST_Username
"
]
||
[
-z
"
$KINGHOST_Password
"
]
;
then
KINGHOST_Username
=
""
KINGHOST_Password
=
""
_err
"You don't specify KingHost api password and email yet."
_err
"Please create you key and try again."
return
1
fi
#save the credentials to the account conf file.
_saveaccountconf_mutable KINGHOST_Username
"
$KINGHOST_Username
"
_saveaccountconf_mutable KINGHOST_Password
"
$KINGHOST_Password
"
_debug
"Getting txt records"
_kinghost_rest GET
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
#This API call returns "status":"ok" if dns record does not exists
#We are creating a new txt record here, so we expect the "ok" status
if
!
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
_kinghost_rest POST
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
if
!
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
return
0
;
fulldomain
=
$1
txtvalue
=
$2
KINGHOST_Username
=
"
${
KINGHOST_Username
:-
$(
_readaccountconf_mutable KINGHOST_Username
)
}
"
KINGHOST_Password
=
"
${
KINGHOST_Password
:-
$(
_readaccountconf_mutable KINGHOST_Password
)
}
"
if
[
-z
"
$KINGHOST_Username
"
]
||
[
-z
"
$KINGHOST_Password
"
]
;
then
KINGHOST_Username
=
""
KINGHOST_Password
=
""
_err
"You don't specify KingHost api password and email yet."
_err
"Please create you key and try again."
return
1
fi
#save the credentials to the account conf file.
_saveaccountconf_mutable KINGHOST_Username
"
$KINGHOST_Username
"
_saveaccountconf_mutable KINGHOST_Password
"
$KINGHOST_Password
"
_debug
"Getting txt records"
_kinghost_rest GET
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
#This API call returns "status":"ok" if dns record does not exists
#We are creating a new txt record here, so we expect the "ok" status
if
!
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
_kinghost_rest POST
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
if
!
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
return
0
;
}
# Usage: fulldomain txtvalue
# Used to remove the txt record after validation
dns_kinghost_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
KINGHOST_Password
=
"
${
KINGHOST_Password
:-
$(
_readaccountconf_mutable KINGHOST_Password
)
}
"
KINGHOST_Username
=
"
${
KINGHOST_Username
:-
$(
_readaccountconf_mutable KINGHOST_Username
)
}
"
if
[
-z
"
$KINGHOST_Password
"
]
||
[
-z
"
$KINGHOST_Username
"
]
;
then
KINGHOST_Password
=
""
KINGHOST_Username
=
""
_err
"You don't specify KingHost api key and email yet."
_err
"Please create you key and try again."
return
1
fi
_debug
"Getting txt records"
_kinghost_rest GET
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
#This API call returns "status":"ok" if dns record does not exists
#We are removing a txt record here, so the record must exists
if
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
_kinghost_rest DELETE
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
if
!
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
return
0
;
fulldomain
=
$1
txtvalue
=
$2
KINGHOST_Password
=
"
${
KINGHOST_Password
:-
$(
_readaccountconf_mutable KINGHOST_Password
)
}
"
KINGHOST_Username
=
"
${
KINGHOST_Username
:-
$(
_readaccountconf_mutable KINGHOST_Username
)
}
"
if
[
-z
"
$KINGHOST_Password
"
]
||
[
-z
"
$KINGHOST_Username
"
]
;
then
KINGHOST_Password
=
""
KINGHOST_Username
=
""
_err
"You don't specify KingHost api key and email yet."
_err
"Please create you key and try again."
return
1
fi
_debug
"Getting txt records"
_kinghost_rest GET
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
#This API call returns "status":"ok" if dns record does not exists
#We are removing a txt record here, so the record must exists
if
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
_kinghost_rest DELETE
"dns"
"name=
$fulldomain
&content=
$txtvalue
"
if
!
echo
"
$response
"
|
grep
'"status":"ok"'
>
/dev/null
;
then
_err
"Error"
_err
"
$response
"
return
1
fi
return
0
;
}
#################### Private functions below ##################################
...
...
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