From 63089357831022ab5f00c998af608251cc1fc62e Mon Sep 17 00:00:00 2001 From: hyper Date: Mon, 21 Nov 2016 13:24:32 +0100 Subject: [PATCH] Added credentials check and saving --- dnsapi/dns_ispconfig.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dnsapi/dns_ispconfig.sh b/dnsapi/dns_ispconfig.sh index 298c0d78..c4b1a472 100755 --- a/dnsapi/dns_ispconfig.sh +++ b/dnsapi/dns_ispconfig.sh @@ -15,7 +15,7 @@ dns_ispconfig_add() { fulldomain="${1}" txtvalue="${2}" - _ISPC_login && _ISPC_getZoneInfo && _ISPC_addTxt || return 1 + _ISPC_Credentials && _ISPC_login && _ISPC_getZoneInfo && _ISPC_addTxt || return 1 } #Usage: dns_myapi_rm _acme-challenge.www.domain.com @@ -26,6 +26,20 @@ dns_ispconfig_rm() { #################### Private functions bellow ################################## +_ISPC_credentials() { + if [ -z "$ISPC_User" ] || [ -z "$ISPC_Password" ] || [ -z "$ISPC_Api" ]; then + ISPC_User="" + ISPC_Password="" + ISPC_Api="" + _err "You haven't specified the ISPConfig Login data and the URL. Please try again." + return 1 + else + _saveaccountconf ISPC_User "${ISPC_User}" + _saveaccountconf ISPC_Password "${ISPC_Password}" + _saveaccountconf ISPC_Api "${ISPC_Api}" + fi +} + _ISPC_login() { _info "Getting Session ID" curData="{\"username\":\"${ISPC_User}\",\"password\":\"${ISPC_Password}\",\"client_login\":false}"