mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-11-14 10:21:45 +00:00
Merge pull request #2276 from der-berni/dev
updated to work with one.com
This commit is contained in:
commit
6650072fe6
@ -4,6 +4,8 @@
|
|||||||
# one.com ui wrapper for acme.sh
|
# one.com ui wrapper for acme.sh
|
||||||
# Author: github: @diseq
|
# Author: github: @diseq
|
||||||
# Created: 2019-02-17
|
# Created: 2019-02-17
|
||||||
|
# Fixed by: @der-berni
|
||||||
|
# Modified: 2019-05-31
|
||||||
#
|
#
|
||||||
# export ONECOM_User="username"
|
# export ONECOM_User="username"
|
||||||
# export ONECOM_Password="password"
|
# export ONECOM_Password="password"
|
||||||
@ -14,49 +16,29 @@
|
|||||||
# only single domain supported atm
|
# only single domain supported atm
|
||||||
|
|
||||||
dns_one_add() {
|
dns_one_add() {
|
||||||
mysubdomain=$(printf -- "%s" "$1" | rev | cut -d"." -f3- | rev)
|
fulldomain=$1
|
||||||
mydomain=$(printf -- "%s" "$1" | rev | cut -d"." -f1-2 | rev)
|
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
|
|
||||||
# get credentials
|
if ! _dns_one_login; then
|
||||||
ONECOM_User="${ONECOM_User:-$(_readaccountconf_mutable ONECOM_User)}"
|
_err "login failed"
|
||||||
ONECOM_Password="${ONECOM_Password:-$(_readaccountconf_mutable ONECOM_Password)}"
|
|
||||||
if [ -z "$ONECOM_User" ] || [ -z "$ONECOM_Password" ]; then
|
|
||||||
ONECOM_User=""
|
|
||||||
ONECOM_Password=""
|
|
||||||
_err "You didn't specify a one.com username and password yet."
|
|
||||||
_err "Please create the key and try again."
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#save the api key and email to the account conf file.
|
_debug "detect the root domain"
|
||||||
_saveaccountconf_mutable ONECOM_User "$ONECOM_User"
|
if ! _get_root "$fulldomain"; then
|
||||||
_saveaccountconf_mutable ONECOM_Password "$ONECOM_Password"
|
_err "root domain not found"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Login with user and password
|
mysubdomain=$_sub_domain
|
||||||
postdata="loginDomain=true"
|
mydomain=$_domain
|
||||||
postdata="$postdata&displayUsername=$ONECOM_User"
|
_debug mysubdomain "$mysubdomain"
|
||||||
postdata="$postdata&username=$ONECOM_User"
|
_debug mydomain "$mydomain"
|
||||||
postdata="$postdata&targetDomain=$mydomain"
|
|
||||||
postdata="$postdata&password1=$ONECOM_Password"
|
|
||||||
postdata="$postdata&loginTarget="
|
|
||||||
#_debug postdata "$postdata"
|
|
||||||
|
|
||||||
response="$(_post "$postdata" "https://www.one.com/admin/login.do" "" "POST" "application/x-www-form-urlencoded")"
|
|
||||||
#_debug response "$response"
|
|
||||||
|
|
||||||
JSESSIONID="$(grep "JSESSIONID" "$HTTP_HEADER" | grep "^[Ss]et-[Cc]ookie:" | _tail_n 1 | _egrep_o 'JSESSIONID=[^;]*;' | tr -d ';')"
|
|
||||||
_debug jsessionid "$JSESSIONID"
|
|
||||||
|
|
||||||
export _H1="Cookie: ${JSESSIONID}"
|
|
||||||
|
|
||||||
# get entries
|
# get entries
|
||||||
response="$(_get "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records")"
|
response="$(_get "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records")"
|
||||||
_debug response "$response"
|
_debug response "$response"
|
||||||
|
|
||||||
CSRF_G_TOKEN="$(grep "CSRF_G_TOKEN=" "$HTTP_HEADER" | grep "^Set-Cookie:" | _tail_n 1 | _egrep_o 'CSRF_G_TOKEN=[^;]*;' | tr -d ';')"
|
|
||||||
export _H2="Cookie: ${CSRF_G_TOKEN}"
|
|
||||||
|
|
||||||
# Update the IP address for domain entry
|
# Update the IP address for domain entry
|
||||||
postdata="{\"type\":\"dns_custom_records\",\"attributes\":{\"priority\":0,\"ttl\":600,\"type\":\"TXT\",\"prefix\":\"$mysubdomain\",\"content\":\"$txtvalue\"}}"
|
postdata="{\"type\":\"dns_custom_records\",\"attributes\":{\"priority\":0,\"ttl\":600,\"type\":\"TXT\",\"prefix\":\"$mysubdomain\",\"content\":\"$txtvalue\"}}"
|
||||||
_debug postdata "$postdata"
|
_debug postdata "$postdata"
|
||||||
@ -77,45 +59,30 @@ dns_one_add() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dns_one_rm() {
|
dns_one_rm() {
|
||||||
mysubdomain=$(printf -- "%s" "$1" | rev | cut -d"." -f3- | rev)
|
fulldomain=$1
|
||||||
mydomain=$(printf -- "%s" "$1" | rev | cut -d"." -f1-2 | rev)
|
|
||||||
txtvalue=$2
|
txtvalue=$2
|
||||||
|
|
||||||
# get credentials
|
if ! _dns_one_login; then
|
||||||
ONECOM_User="${ONECOM_User:-$(_readaccountconf_mutable ONECOM_User)}"
|
_err "login failed"
|
||||||
ONECOM_Password="${ONECOM_Password:-$(_readaccountconf_mutable ONECOM_Password)}"
|
|
||||||
if [ -z "$ONECOM_User" ] || [ -z "$ONECOM_Password" ]; then
|
|
||||||
ONECOM_User=""
|
|
||||||
ONECOM_Password=""
|
|
||||||
_err "You didn't specify a one.com username and password yet."
|
|
||||||
_err "Please create the key and try again."
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Login with user and password
|
_debug "detect the root domain"
|
||||||
postdata="loginDomain=true"
|
if ! _get_root "$fulldomain"; then
|
||||||
postdata="$postdata&displayUsername=$ONECOM_User"
|
_err "root domain not found"
|
||||||
postdata="$postdata&username=$ONECOM_User"
|
return 1
|
||||||
postdata="$postdata&targetDomain=$mydomain"
|
fi
|
||||||
postdata="$postdata&password1=$ONECOM_Password"
|
|
||||||
postdata="$postdata&loginTarget="
|
|
||||||
|
|
||||||
response="$(_post "$postdata" "https://www.one.com/admin/login.do" "" "POST" "application/x-www-form-urlencoded")"
|
mysubdomain=$_sub_domain
|
||||||
#_debug response "$response"
|
mydomain=$_domain
|
||||||
|
_debug mysubdomain "$mysubdomain"
|
||||||
JSESSIONID="$(grep "JSESSIONID" "$HTTP_HEADER" | grep "^[Ss]et-[Cc]ookie:" | _tail_n 1 | _egrep_o 'JSESSIONID=[^;]*;' | tr -d ';')"
|
_debug mydomain "$mydomain"
|
||||||
_debug jsessionid "$JSESSIONID"
|
|
||||||
|
|
||||||
export _H1="Cookie: ${JSESSIONID}"
|
|
||||||
|
|
||||||
# get entries
|
# get entries
|
||||||
response="$(_get "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records")"
|
response="$(_get "https://www.one.com/admin/api/domains/$mydomain/dns/custom_records")"
|
||||||
response="$(echo "$response" | _normalizeJson)"
|
response="$(echo "$response" | _normalizeJson)"
|
||||||
_debug response "$response"
|
_debug response "$response"
|
||||||
|
|
||||||
CSRF_G_TOKEN="$(grep "CSRF_G_TOKEN=" "$HTTP_HEADER" | grep "^Set-Cookie:" | _tail_n 1 | _egrep_o 'CSRF_G_TOKEN=[^;]*;' | tr -d ';')"
|
|
||||||
export _H2="Cookie: ${CSRF_G_TOKEN}"
|
|
||||||
|
|
||||||
id=$(printf -- "%s" "$response" | sed -n "s/.*{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"$mysubdomain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"priority\":0,\"ttl\":600}.*/\1/p")
|
id=$(printf -- "%s" "$response" | sed -n "s/.*{\"type\":\"dns_custom_records\",\"id\":\"\([^\"]*\)\",\"attributes\":{\"prefix\":\"$mysubdomain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"priority\":0,\"ttl\":600}.*/\1/p")
|
||||||
|
|
||||||
if [ -z "$id" ]; then
|
if [ -z "$id" ]; then
|
||||||
@ -137,3 +104,76 @@ dns_one_rm() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#_acme-challenge.www.domain.com
|
||||||
|
#returns
|
||||||
|
# _sub_domain=_acme-challenge.www
|
||||||
|
# _domain=domain.com
|
||||||
|
_get_root() {
|
||||||
|
domain="$1"
|
||||||
|
i=2
|
||||||
|
p=1
|
||||||
|
while true; do
|
||||||
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||||
|
|
||||||
|
if [ -z "$h" ]; then
|
||||||
|
#not valid
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
response="$(_get "https://www.one.com/admin/api/domains/$h/dns/custom_records")"
|
||||||
|
|
||||||
|
if ! _contains "$response" "CRMRST_000302"; then
|
||||||
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||||
|
_domain="$h"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
p=$i
|
||||||
|
i=$(_math "$i" + 1)
|
||||||
|
done
|
||||||
|
_err "Unable to parse this domain"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_dns_one_login() {
|
||||||
|
|
||||||
|
# get credentials
|
||||||
|
ONECOM_User="${ONECOM_User:-$(_readaccountconf_mutable ONECOM_User)}"
|
||||||
|
ONECOM_Password="${ONECOM_Password:-$(_readaccountconf_mutable ONECOM_Password)}"
|
||||||
|
if [ -z "$ONECOM_User" ] || [ -z "$ONECOM_Password" ]; then
|
||||||
|
ONECOM_User=""
|
||||||
|
ONECOM_Password=""
|
||||||
|
_err "You didn't specify a one.com username and password yet."
|
||||||
|
_err "Please create the key and try again."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#save the api key and email to the account conf file.
|
||||||
|
_saveaccountconf_mutable ONECOM_User "$ONECOM_User"
|
||||||
|
_saveaccountconf_mutable ONECOM_Password "$ONECOM_Password"
|
||||||
|
|
||||||
|
# Login with user and password
|
||||||
|
postdata="loginDomain=true"
|
||||||
|
postdata="$postdata&displayUsername=$ONECOM_User"
|
||||||
|
postdata="$postdata&username=$ONECOM_User"
|
||||||
|
postdata="$postdata&targetDomain="
|
||||||
|
postdata="$postdata&password1=$ONECOM_Password"
|
||||||
|
postdata="$postdata&loginTarget="
|
||||||
|
#_debug postdata "$postdata"
|
||||||
|
|
||||||
|
response="$(_post "$postdata" "https://www.one.com/admin/login.do" "" "POST" "application/x-www-form-urlencoded")"
|
||||||
|
#_debug response "$response"
|
||||||
|
|
||||||
|
# Get SessionID
|
||||||
|
JSESSIONID="$(grep "OneSIDCrmAdmin" "$HTTP_HEADER" | grep "^[Ss]et-[Cc]ookie:" | _head_n 1 | _egrep_o 'OneSIDCrmAdmin=[^;]*;' | tr -d ';')"
|
||||||
|
_debug jsessionid "$JSESSIONID"
|
||||||
|
|
||||||
|
if [ -z "$JSESSIONID" ]; then
|
||||||
|
_err "error sessionid cookie not found"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export _H1="Cookie: ${JSESSIONID}"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user