_err "You didn't specify PowerDNS Mysql username."
_err "Please set PDNS_User and try again."
return1
fi
if[ -z "$PDNS_Pass"];then
PDNS_Pass=""
_err "You didn't specify PowerDNS Mysql password."
_err "Please set PDNS_Pass and try again."
return1
fi
if[ -z "$PDNS_Database"];then
PDNS_Database=""
_err "You didn't specify PowerDNS Mysql database."
_err "Please set PDNS_Database and try again."
return1
fi
if[ -z "$PDNS_Ttl"];then
PDNS_Ttl="$DEFAULT_PDNS_TTL"
fi
#save the api addr and key to the account conf file.
_saveaccountconf PDNS_Host "$PDNS_Host"
_saveaccountconf PDNS_Port "$PDNS_Port"
_saveaccountconf PDNS_User "$PDNS_User"
_saveaccountconf PDNS_Pass "$PDNS_Pass"
_saveaccountconf PDNS_Database "$PDNS_Database"
if["$PDNS_Ttl" !="$DEFAULT_PDNS_TTL"];then
_saveaccountconf PDNS_Ttl "$PDNS_Ttl"
fi
_domain_id=$(mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "SELECT id FROM ${PDNS_Database}.domains WHERE name='${root}';")
if[ -z "$_domain_id"];then
return1
@ -141,6 +203,67 @@ rm_record() {
root=$1
full=$2
if ! _exists mysql;then
_err "'mysql not found. It seems that mysql client is not installed.'"
_err "You didn't specify PowerDNS Mysql username."
_err "Please set PDNS_User and try again."
return1
fi
if[ -z "$PDNS_Pass"];then
PDNS_Pass=""
_err "You didn't specify PowerDNS Mysql password."
_err "Please set PDNS_Pass and try again."
return1
fi
if[ -z "$PDNS_Database"];then
PDNS_Database=""
_err "You didn't specify PowerDNS Mysql database."
_err "Please set PDNS_Database and try again."
return1
fi
if[ -z "$PDNS_Ttl"];then
PDNS_Ttl="$DEFAULT_PDNS_TTL"
fi
#save the api addr and key to the account conf file.
_saveaccountconf PDNS_Host "$PDNS_Host"
_saveaccountconf PDNS_Port "$PDNS_Port"
_saveaccountconf PDNS_User "$PDNS_User"
_saveaccountconf PDNS_Pass "$PDNS_Pass"
_saveaccountconf PDNS_Database "$PDNS_Database"
if["$PDNS_Ttl" !="$DEFAULT_PDNS_TTL"];then
_saveaccountconf PDNS_Ttl "$PDNS_Ttl"
fi
_pdns_rm=$(mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "DELETE FROM ${PDNS_Database}.records WHERE name='${full}' AND type='TXT';")
if[ -z "$_pdns_rm"];then
@ -157,6 +280,68 @@ rm_record() {
notify_slaves(){
root=$1
# hack set last_check to null to force update. #
if ! _exists mysql;then
_err "'mysql not found. It seems that mysql client is not installed.'"
_err "You didn't specify PowerDNS Mysql username."
_err "Please set PDNS_User and try again."
return1
fi
if[ -z "$PDNS_Pass"];then
PDNS_Pass=""
_err "You didn't specify PowerDNS Mysql password."
_err "Please set PDNS_Pass and try again."
return1
fi
if[ -z "$PDNS_Database"];then
PDNS_Database=""
_err "You didn't specify PowerDNS Mysql database."
_err "Please set PDNS_Database and try again."
return1
fi
if[ -z "$PDNS_Ttl"];then
PDNS_Ttl="$DEFAULT_PDNS_TTL"
fi
#save the api addr and key to the account conf file.
_saveaccountconf PDNS_Host "$PDNS_Host"
_saveaccountconf PDNS_Port "$PDNS_Port"
_saveaccountconf PDNS_User "$PDNS_User"
_saveaccountconf PDNS_Pass "$PDNS_Pass"
_saveaccountconf PDNS_Database "$PDNS_Database"
if["$PDNS_Ttl" !="$DEFAULT_PDNS_TTL"];then
_saveaccountconf PDNS_Ttl "$PDNS_Ttl"
fi
_pdns_notify=$(mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "UPDATE ${PDNS_Database}.domains SET last_check=NULL WHERE name='${root}';")
if[ -z "$_pdns_notify"];then
@ -173,6 +358,68 @@ notify_slaves() {
_get_root(){
domain=$1
i=1
if ! _exists mysql;then
_err "'mysql not found. It seems that mysql client is not installed.'"