From fd72cced13e37c3a5f877e14825bac2d6c455a2a Mon Sep 17 00:00:00 2001 From: neilpang Date: Sun, 12 Feb 2017 10:10:53 +0800 Subject: [PATCH 1/2] move the backup file to acme home fix https://github.com/Neilpang/acme.sh/issues/488 --- acme.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/acme.sh b/acme.sh index 9929dfad..5ce5b803 100755 --- a/acme.sh +++ b/acme.sh @@ -2059,6 +2059,10 @@ _initpath() { _debug DOMAIN_PATH "$DOMAIN_PATH" fi + if [ -z "$DOMAIN_BACKUP_PATH" ]; then + DOMAIN_BACKUP_PATH="$DOMAIN_PATH" + fi + if [ -z "$DOMAIN_CONF" ]; then DOMAIN_CONF="$DOMAIN_PATH/$domain.conf" fi @@ -3612,7 +3616,7 @@ _installcert() { _info "Installing cert to:$Le_RealCertPath" if [ -f "$Le_RealCertPath" ] && [ ! "$IS_RENEW" ]; then - cp "$Le_RealCertPath" "$Le_RealCertPath".bak + cp "$Le_RealCertPath" "$DOMAIN_BACKUP_PATH/cert.bak" fi cat "$CERT_PATH" >"$Le_RealCertPath" fi @@ -3625,7 +3629,7 @@ _installcert() { cat "$CA_CERT_PATH" >>"$Le_RealCACertPath" else if [ -f "$Le_RealCACertPath" ] && [ ! "$IS_RENEW" ]; then - cp "$Le_RealCACertPath" "$Le_RealCACertPath".bak + cp "$Le_RealCACertPath" "$DOMAIN_BACKUP_PATH/ca.bak" fi cat "$CA_CERT_PATH" >"$Le_RealCACertPath" fi @@ -3635,7 +3639,7 @@ _installcert() { _info "Installing key to:$Le_RealKeyPath" if [ -f "$Le_RealKeyPath" ] && [ ! "$IS_RENEW" ]; then - cp "$Le_RealKeyPath" "$Le_RealKeyPath".bak + cp "$Le_RealKeyPath" "$DOMAIN_BACKUP_PATH/key.bak" fi cat "$CERT_KEY_PATH" >"$Le_RealKeyPath" fi @@ -3644,7 +3648,7 @@ _installcert() { _info "Installing full chain to:$Le_RealFullChainPath" if [ -f "$Le_RealFullChainPath" ] && [ ! "$IS_RENEW" ]; then - cp "$Le_RealFullChainPath" "$Le_RealFullChainPath".bak + cp "$Le_RealFullChainPath" "$DOMAIN_BACKUP_PATH/fullchain.bak" fi cat "$CERT_FULLCHAIN_PATH" >"$Le_RealFullChainPath" fi From d88f8e862bc33d4d989be7acb1e1f05049e0163f Mon Sep 17 00:00:00 2001 From: neilpang Date: Sun, 12 Feb 2017 10:20:50 +0800 Subject: [PATCH 2/2] move backup to sub folder. --- acme.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index 5ce5b803..f03501b4 100755 --- a/acme.sh +++ b/acme.sh @@ -2060,7 +2060,7 @@ _initpath() { fi if [ -z "$DOMAIN_BACKUP_PATH" ]; then - DOMAIN_BACKUP_PATH="$DOMAIN_PATH" + DOMAIN_BACKUP_PATH="$DOMAIN_PATH/backup" fi if [ -z "$DOMAIN_CONF" ]; then @@ -3616,6 +3616,7 @@ _installcert() { _info "Installing cert to:$Le_RealCertPath" if [ -f "$Le_RealCertPath" ] && [ ! "$IS_RENEW" ]; then + mkdir -p "$DOMAIN_BACKUP_PATH" cp "$Le_RealCertPath" "$DOMAIN_BACKUP_PATH/cert.bak" fi cat "$CERT_PATH" >"$Le_RealCertPath" @@ -3629,6 +3630,7 @@ _installcert() { cat "$CA_CERT_PATH" >>"$Le_RealCACertPath" else if [ -f "$Le_RealCACertPath" ] && [ ! "$IS_RENEW" ]; then + mkdir -p "$DOMAIN_BACKUP_PATH" cp "$Le_RealCACertPath" "$DOMAIN_BACKUP_PATH/ca.bak" fi cat "$CA_CERT_PATH" >"$Le_RealCACertPath" @@ -3639,6 +3641,7 @@ _installcert() { _info "Installing key to:$Le_RealKeyPath" if [ -f "$Le_RealKeyPath" ] && [ ! "$IS_RENEW" ]; then + mkdir -p "$DOMAIN_BACKUP_PATH" cp "$Le_RealKeyPath" "$DOMAIN_BACKUP_PATH/key.bak" fi cat "$CERT_KEY_PATH" >"$Le_RealKeyPath" @@ -3648,6 +3651,7 @@ _installcert() { _info "Installing full chain to:$Le_RealFullChainPath" if [ -f "$Le_RealFullChainPath" ] && [ ! "$IS_RENEW" ]; then + mkdir -p "$DOMAIN_BACKUP_PATH" cp "$Le_RealFullChainPath" "$DOMAIN_BACKUP_PATH/fullchain.bak" fi cat "$CERT_FULLCHAIN_PATH" >"$Le_RealFullChainPath"