|
|
@ -15,29 +15,16 @@ dns_plesk_add() { |
|
|
fulldomain=$1 |
|
|
fulldomain=$1 |
|
|
txtvalue=$2 |
|
|
txtvalue=$2 |
|
|
|
|
|
|
|
|
PLESK_Host="${CF_Key:-$(_readaccountconf_mutable PLESK_Host)}" |
|
|
|
|
|
PLESK_User="${CF_Key:-$(_readaccountconf_mutable PLESK_User)}" |
|
|
|
|
|
PLESK_Password="${CF_Key:-$(_readaccountconf_mutable PLESK_Password)}" |
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$PLESK_Host" ] || [ -z "$PLESK_User" ] || [ -z "$PLESK_Password"]; then |
|
|
|
|
|
PLESK_Host="" |
|
|
|
|
|
PLESK_User="" |
|
|
|
|
|
PLESK_Password="" |
|
|
|
|
|
_err "You didn't specify a plesk credentials yet." |
|
|
|
|
|
_err "Please create the key and try again." |
|
|
|
|
|
|
|
|
if ! init_config; then |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
#save the api key and email to the account conf file. |
|
|
|
|
|
_saveaccountconf_mutable PLESK_Host "$PLESK_Host" |
|
|
|
|
|
_saveaccountconf_mutable PLESK_User "$PLESK_User" |
|
|
|
|
|
_saveaccountconf_mutable PLESK_Password "$PLESK_Password" |
|
|
|
|
|
|
|
|
|
|
|
_debug "First detect the root zone" |
|
|
_debug "First detect the root zone" |
|
|
if ! _get_root "$fulldomain"; then |
|
|
if ! _get_root "$fulldomain"; then |
|
|
_err "invalid domain" |
|
|
_err "invalid domain" |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_debug _domain_id "$_domain_id" |
|
|
_debug _domain_id "$_domain_id" |
|
|
_debug _sub_domain "$_sub_domain" |
|
|
_debug _sub_domain "$_sub_domain" |
|
|
_debug _domain "$_domain" |
|
|
_debug _domain "$_domain" |
|
|
@ -52,29 +39,16 @@ dns_plesk_rm() { |
|
|
fulldomain=$1 |
|
|
fulldomain=$1 |
|
|
txtvalue=$2 |
|
|
txtvalue=$2 |
|
|
|
|
|
|
|
|
PLESK_Host="${CF_Key:-$(_readaccountconf_mutable PLESK_Host)}" |
|
|
|
|
|
PLESK_User="${CF_Key:-$(_readaccountconf_mutable PLESK_User)}" |
|
|
|
|
|
PLESK_Password="${CF_Key:-$(_readaccountconf_mutable PLESK_Password)}" |
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$PLESK_Host" ] || [ -z "$PLESK_User" ] || [ -z "$PLESK_Password"]; then |
|
|
|
|
|
PLESK_Host="" |
|
|
|
|
|
PLESK_User="" |
|
|
|
|
|
PLESK_Password="" |
|
|
|
|
|
_err "You didn't specify a plesk credentials yet." |
|
|
|
|
|
_err "Please create the key and try again." |
|
|
|
|
|
|
|
|
if ! init_config; then |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
#save the api key and email to the account conf file. |
|
|
|
|
|
_saveaccountconf_mutable PLESK_Host "$PLESK_Host" |
|
|
|
|
|
_saveaccountconf_mutable PLESK_User "$PLESK_User" |
|
|
|
|
|
_saveaccountconf_mutable PLESK_Password "$PLESK_Password" |
|
|
|
|
|
|
|
|
|
|
|
_debug "First detect the root zone" |
|
|
_debug "First detect the root zone" |
|
|
if ! _get_root "$fulldomain"; then |
|
|
if ! _get_root "$fulldomain"; then |
|
|
_err "invalid domain" |
|
|
_err "invalid domain" |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_debug _domain_id "$_domain_id" |
|
|
_debug _domain_id "$_domain_id" |
|
|
_debug _sub_domain "$_sub_domain" |
|
|
_debug _sub_domain "$_sub_domain" |
|
|
_debug _domain "$_domain" |
|
|
_debug _domain "$_domain" |
|
|
@ -83,6 +57,27 @@ dns_plesk_rm() { |
|
|
del_txt_record $_domain_id $fulldomain |
|
|
del_txt_record $_domain_id $fulldomain |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#################### Private functions below ################################## |
|
|
|
|
|
function init_config(){ |
|
|
|
|
|
PLESK_Host="${PLESK_Host:-$(_readaccountconf_mutable PLESK_Host)}" |
|
|
|
|
|
PLESK_User="${PLESK_User:-$(_readaccountconf_mutable PLESK_User)}" |
|
|
|
|
|
PLESK_Password="${PLESK_Password:-$(_readaccountconf_mutable PLESK_Password)}" |
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$PLESK_Host" ] || [ -z "$PLESK_User" ] || [ -z "$PLESK_Password" ]; then |
|
|
|
|
|
PLESK_Host="" |
|
|
|
|
|
PLESK_User="" |
|
|
|
|
|
PLESK_Password="" |
|
|
|
|
|
_err "You didn't specify a plesk credentials 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 PLESK_Host "$PLESK_Host" |
|
|
|
|
|
_saveaccountconf_mutable PLESK_User "$PLESK_User" |
|
|
|
|
|
_saveaccountconf_mutable PLESK_Password "$PLESK_Password" |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function plesk_api() { |
|
|
function plesk_api() { |
|
|
local request="$1" |
|
|
local request="$1" |
|
|
@ -106,9 +101,9 @@ function add_txt_record() { |
|
|
plesk_api $request |
|
|
plesk_api $request |
|
|
|
|
|
|
|
|
if ! _contains "${response}" '<status>ok</status>'; then |
|
|
if ! _contains "${response}" '<status>ok</status>'; then |
|
|
return 1 |
|
|
|
|
|
|
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
return 0 |
|
|
|
|
|
|
|
|
return 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function del_txt_record() { |
|
|
function del_txt_record() { |
|
|
@ -137,6 +132,7 @@ function del_txt_record() { |
|
|
return 0 |
|
|
return 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#fetches the domain list for the given account |
|
|
function get_domain_list() { |
|
|
function get_domain_list() { |
|
|
local request='<packet><customer><get-domain-list><filter></filter></get-domain-list></customer></packet>' |
|
|
local request='<packet><customer><get-domain-list><filter></filter></get-domain-list></customer></packet>' |
|
|
|
|
|
|
|
|
@ -148,10 +144,11 @@ function get_domain_list() { |
|
|
|
|
|
|
|
|
_plesk_domain_names=($(echo "${response}" | sed -nr 's_<name>(.*)</name>_\1_p')); |
|
|
_plesk_domain_names=($(echo "${response}" | sed -nr 's_<name>(.*)</name>_\1_p')); |
|
|
_plesk_domain_ids=($(echo "${response}"| sed -nr 's_<id>(.*)</id>_\1_p')); |
|
|
_plesk_domain_ids=($(echo "${response}"| sed -nr 's_<id>(.*)</id>_\1_p')); |
|
|
_plesk_domain_ids=("${_plesk_domain_ids[@]:1}") |
|
|
|
|
|
|
|
|
_plesk_domain_ids=("${_plesk_domain_ids[@]:1}") #remove first entry because it is the customer id |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#fetches all dns records fo rthe given sit |
|
|
function get_dns_record_list() { |
|
|
function get_dns_record_list() { |
|
|
local siteid=$1 |
|
|
local siteid=$1 |
|
|
local request="<packet><dns><get_rec><filter><site-id>$siteid</site-id></filter></get_rec></dns></packet>" |
|
|
local request="<packet><dns><get_rec><filter><site-id>$siteid</site-id></filter></get_rec></dns></packet>" |
|
|
@ -167,20 +164,6 @@ function get_dns_record_list() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#urls=($(sed -nr 's_<id>(.*)</id>_\1_p' resp.txt)); echo ${urls[@]} |
|
|
|
|
|
|
|
|
|
|
|
#domain.com |
|
|
|
|
|
#returns |
|
|
|
|
|
# _plesk_site_id=22 |
|
|
|
|
|
function get_site_id() { |
|
|
|
|
|
local site_name=$1 |
|
|
|
|
|
request="<packet><site><get><filter><name>$site_name</name></filter><dataset><gen_info/></dataset></get></site></packet>" |
|
|
|
|
|
plesk_api $request |
|
|
|
|
|
echo $resonse |
|
|
|
|
|
_plesk_site_id="$(echo $response | grep -Po '(?<=<id>).*?(?=</id>)')" |
|
|
|
|
|
return 0 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#_acme-challenge.www.domain.com |
|
|
#_acme-challenge.www.domain.com |
|
|
#returns |
|
|
#returns |
|
|
# _sub_domain=_acme-challenge.www |
|
|
# _sub_domain=_acme-challenge.www |
|
|
|