init dnsapi

This commit is contained in:
neil
2016-01-30 21:00:36 +08:00
parent bb2294e761
commit 175c9decd7
2 changed files with 187 additions and 13 deletions

61
le.sh
View File

@@ -320,7 +320,6 @@ _initpath() {
if [ -z "$CA_CERT_PATH" ] ; then
CA_CERT_PATH="$WORKING_DIR/$domain/ca.cer"
fi
}
@@ -619,12 +618,44 @@ issue() {
_debug txt "$txt"
#dns
#1. check use api
_err "Add the following TXT record:"
_err "Domain: $txtdomain"
_err "TXT value: $txt"
_err "Please be aware that you prepend _acme-challenge. before your domain"
_err "so the resulting subdomain will be: $txtdomain"
#dnsadded='1'
d_api=""
if [ -f "$WORKING_DIR/$d/$Le_Webroot" ] ; then
d_api="$WORKING_DIR/$d/$Le_Webroot"
elif [ -f "$WORKING_DIR/$d/$Le_Webroot.sh" ] ; then
d_api="$WORKING_DIR/$d/$Le_Webroot.sh"
elif [ -f "$WORKING_DIR/$Le_Webroot" ] ; then
d_api="$WORKING_DIR/$Le_Webroot"
elif [ -f "$WORKING_DIR/$Le_Webroot.sh" ] ; then
d_api="$WORKING_DIR/$Le_Webroot.sh"
fi
if [ "$d_api" ]; then
_info "Found domain api file: $d_api"
else
_err "Add the following TXT record:"
_err "Domain: $txtdomain"
_err "TXT value: $txt"
_err "Please be aware that you prepend _acme-challenge. before your domain"
_err "so the resulting subdomain will be: $txtdomain"
continue
fi
if ! source $d_api ; then
_err "Load file $d_api error. Please check your api file and try again."
return 1
fi
addcommand="$Le_Webroot-add"
if ! command -v $addcommand ; then
_err "It seems that your api file is not correct, it must have a function named: $Le_Webroot"
return 1
fi
if ! $addcommand $txtdomain $txt ; then
_err "Error add txt for domain:$txtdomain"
return 1
fi
dnsadded='1'
fi
done
@@ -806,13 +837,17 @@ renew() {
_initpath $Le_Domain
if [ -f "$DOMAIN_CONF" ] ; then
source "$DOMAIN_CONF"
if [ -z "$FORCE" ] && [ "$Le_NextRenewTime" ] && [ "$(date -u "+%s" )" -lt "$Le_NextRenewTime" ] ; then
_info "Skip, Next renewal time is: $Le_NextRenewTimeStr"
return 2
fi
if [ ! -f "$DOMAIN_CONF" ] ; then
_err "$Le_Domain is not a issued domain, skip."
return 1;
fi
source "$DOMAIN_CONF"
if [ -z "$FORCE" ] && [ "$Le_NextRenewTime" ] && [ "$(date -u "+%s" )" -lt "$Le_NextRenewTime" ] ; then
_info "Skip, Next renewal time is: $Le_NextRenewTimeStr"
return 2
fi
IS_RENEW="1"
issue "$Le_Webroot" "$Le_Domain" "$Le_Alt" "$Le_Keylength" "$Le_RealCertPath" "$Le_RealKeyPath" "$Le_RealCACertPath" "$Le_ReloadCmd"
IS_RENEW=""