From e9209938cb292203154423a68ce26c0df54058b3 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 31 Jan 2016 16:30:01 +0800 Subject: [PATCH 1/2] support account config file to save dns api key --- dnsapi/dns-cf.sh | 4 ++++ le.sh | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dnsapi/dns-cf.sh b/dnsapi/dns-cf.sh index 7cb086b8..b1e4b47d 100755 --- a/dnsapi/dns-cf.sh +++ b/dnsapi/dns-cf.sh @@ -22,6 +22,10 @@ dns-cf-add() { return 1 fi + #save the api key and email to the account conf file. + _saveaccountconf CF_Key "$CF_Key" + _saveaccountconf CF_Email "$CF_Email" + _debug "First detect the root zone" if ! _get_root $fulldomain ; then _err "invalid domain" diff --git a/le.sh b/le.sh index 768efcf7..1646d6f2 100755 --- a/le.sh +++ b/le.sh @@ -242,6 +242,29 @@ _setopt() { _debug "$(grep -H -n "^$__opt$__sep" $__conf)" } +#_savedomainconf key value +#save to domain.conf +_savedomainconf() { + key="$1" + value="$2" + if [ "$DOMAIN_CONF" ] ; then + _setopt $DOMAIN_CONF "$key" "=" "$value" + else + _debug "DOMAIN_CONF is empty, can not save $key=$value" + fi +} + +#_saveaccountconf key value +_saveaccountconf() { + key="$1" + value="$2" + if [ "$ACCOUNT_CONF_PATH" ] ; then + _setopt $ACCOUNT_CONF_PATH "$key" "=" "$value" + else + _debug "ACCOUNT_CONF_PATH is empty, can not save $key=$value" + fi +} + _startserver() { content="$1" _NC="nc -q 1" @@ -296,7 +319,15 @@ _initpath() { mkdir -p "$WORKING_DIR" if [ -z "$ACCOUNT_KEY_PATH" ] ; then - ACCOUNT_KEY_PATH="$WORKING_DIR/account.acc" + ACCOUNT_KEY_PATH="$WORKING_DIR/account.key" + fi + + if [ -z "$ACCOUNT_CONF_PATH" ] ; then + ACCOUNT_CONF_PATH="$WORKING_DIR/account.conf" + fi + + if [ -f "$ACCOUNT_CONF_PATH" ] ; then + source "$ACCOUNT_CONF_PATH" fi if [ -z "$domain" ] ; then From b25d22b05a6e199817e3baf42de31dd2b908b1ee Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 31 Jan 2016 16:38:52 +0800 Subject: [PATCH 2/2] keep compatible --- le.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/le.sh b/le.sh index 1646d6f2..b2d7f1f9 100755 --- a/le.sh +++ b/le.sh @@ -1,5 +1,5 @@ #!/bin/bash -VER=1.1.2 +VER=1.1.3 PROJECT="https://github.com/Neilpang/le" DEFAULT_CA="https://acme-v01.api.letsencrypt.org" @@ -1071,6 +1071,11 @@ install() { mkdir -p $WORKING_DIR/dnsapi cp dnsapi/* $WORKING_DIR/dnsapi/ + #to keep compatible mv the .acc file to .key file + if [ -f "$WORKING_DIR/account.acc" ] ; then + mv "$WORKING_DIR/account.acc" "$WORKING_DIR/account.key" + fi + installcronjob _info OK