add --certhome for --install command to save all the certs.

This commit is contained in:
neil 2016-04-16 19:05:53 +08:00
parent 5ef501c5ec
commit b281789777
2 changed files with 30 additions and 9 deletions

View File

@ -148,6 +148,7 @@ Parameters:
--accountconf Specifies a customized account config file. --accountconf Specifies a customized account config file.
--home Specifies the home dir for acme.sh . --home Specifies the home dir for acme.sh .
--certhome Specifies the home dir to save all the certs, only valid for '--install' command.
--useragent Specifies the user agent string. it will be saved for future use too. --useragent Specifies the user agent string. it will be saved for future use too.
--accountemail Specifies the account email for registering, Only valid for the '--install' command. --accountemail Specifies the account email for registering, Only valid for the '--install' command.
--accountkey Specifies the account key path, Only valid for the '--install' command. --accountkey Specifies the account key path, Only valid for the '--install' command.

36
acme.sh
View File

@ -741,17 +741,23 @@ _initpath() {
CURL="$CURL -L --trace-ascii $dp " CURL="$CURL -L --trace-ascii $dp "
fi fi
domain="$1" _DEFAULT_ACCOUNT_KEY_PATH="$LE_WORKING_DIR/account.key"
if [[ -z "$ACCOUNT_KEY_PATH" ]] ; then if [[ -z "$ACCOUNT_KEY_PATH" ]] ; then
ACCOUNT_KEY_PATH="$LE_WORKING_DIR/account.key" ACCOUNT_KEY_PATH="$_DEFAULT_ACCOUNT_KEY_PATH"
fi fi
domain="$1"
if [[ -z "$domain" ]] ; then if [[ -z "$domain" ]] ; then
return 0 return 0
fi fi
domainhome="$LE_WORKING_DIR/$domain" _DEFAULT_CERT_HOME="$LE_WORKING_DIR"
if [[ -z "$CERT_HOME" ]] ; then
CERT_HOME="$_DEFAULT_CERT_HOME"
fi
domainhome="$CERT_HOME/$domain"
mkdir -p "$domainhome" mkdir -p "$domainhome"
if [[ -z "$DOMAIN_PATH" ]] ; then if [[ -z "$DOMAIN_PATH" ]] ; then
@ -1428,7 +1434,7 @@ renewAll() {
_initpath _initpath
_info "renewAll" _info "renewAll"
for d in $(ls -F ${LE_WORKING_DIR}/ | grep [^.].*[.].*/$ ) ; do for d in $(ls -F ${CERT_HOME}/ | grep [^.].*[.].*/$ ) ; do
d=$(echo $d | cut -d '/' -f 1) d=$(echo $d | cut -d '/' -f 1)
_info "renew $d" _info "renew $d"
@ -1679,6 +1685,7 @@ _initconf() {
#ACCOUNT_EMAIL=aaa@aaa.com # the account email used to register account. #ACCOUNT_EMAIL=aaa@aaa.com # the account email used to register account.
#ACCOUNT_KEY_PATH=\"/path/to/account.key\" #ACCOUNT_KEY_PATH=\"/path/to/account.key\"
#CERT_HOME=\"/path/to/cert/home\"
#STAGE=1 # Use the staging api #STAGE=1 # Use the staging api
#FORCE=1 # Force to issue cert #FORCE=1 # Force to issue cert
@ -1829,6 +1836,14 @@ install() {
_setopt "$_DEFAULT_ACCOUNT_CONF_PATH" "ACCOUNT_CONF_PATH" "=" "\"$ACCOUNT_CONF_PATH\"" _setopt "$_DEFAULT_ACCOUNT_CONF_PATH" "ACCOUNT_CONF_PATH" "=" "\"$ACCOUNT_CONF_PATH\""
fi fi
if [[ "$_DEFAULT_CERT_HOME" != "$CERT_HOME" ]] ; then
_saveaccountconf "CERT_HOME" "$CERT_HOME"
fi
if [[ "$_DEFAULT_ACCOUNT_KEY_PATH" != "$ACCOUNT_KEY_PATH" ]] ; then
_saveaccountconf "ACCOUNT_KEY_PATH" "$ACCOUNT_KEY_PATH"
fi
installcronjob installcronjob
_info OK _info OK
@ -1906,6 +1921,7 @@ Parameters:
--accountconf Specifies a customized account config file. --accountconf Specifies a customized account config file.
--home Specifies the home dir for $PROJECT_NAME . --home Specifies the home dir for $PROJECT_NAME .
--certhome Specifies the home dir to save all the certs.
--useragent Specifies the user agent string. it will be saved for future use too. --useragent Specifies the user agent string. it will be saved for future use too.
--accountemail Specifies the account email for registering, Only valid for the '--install' command. --accountemail Specifies the account email for registering, Only valid for the '--install' command.
--accountkey Specifies the account key path, Only valid for the '--install' command. --accountkey Specifies the account key path, Only valid for the '--install' command.
@ -1958,6 +1974,7 @@ _process() {
_useragent="" _useragent=""
_accountemail="" _accountemail=""
_accountkey="" _accountkey=""
_certhome=""
while (( ${#} )); do while (( ${#} )); do
case "${1}" in case "${1}" in
@ -2127,6 +2144,11 @@ _process() {
LE_WORKING_DIR="$2" LE_WORKING_DIR="$2"
shift shift
;; ;;
--certhome)
_certhome="$2"
CERT_HOME="$_certhome"
shift
;;
--useragent) --useragent)
_useragent="$2" _useragent="$2"
USER_AGENT="$_useragent" USER_AGENT="$_useragent"
@ -2204,9 +2226,7 @@ _process() {
if [[ "$_accountemail" ]] ; then if [[ "$_accountemail" ]] ; then
_saveaccountconf "ACCOUNT_EMAIL" "$_accountemail" _saveaccountconf "ACCOUNT_EMAIL" "$_accountemail"
fi fi
if [[ "$_accountkey" ]] ; then
_saveaccountconf "ACCOUNT_KEY_PATH" "$_accountkey"
fi
} }