From 34eb86b2261d587f603c2482a777017983a5afdf Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Thu, 3 Mar 2016 09:44:42 -0800 Subject: [PATCH] trap magic --- letsencrypt-auto-source/letsencrypt-auto | 3 +-- letsencrypt-auto-source/letsencrypt-auto.template | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/letsencrypt-auto-source/letsencrypt-auto b/letsencrypt-auto-source/letsencrypt-auto index 6663e5069c6..be8d50a4d80 100755 --- a/letsencrypt-auto-source/letsencrypt-auto +++ b/letsencrypt-auto-source/letsencrypt-auto @@ -431,7 +431,6 @@ InstallRequirements() { echo "Had a problem while downloading and verifying Python packages:" echo "$PEEP_OUT" rm -rf "$VENV_PATH" - rm -rf "$TEMP_DIR" exit 1 fi } @@ -458,6 +457,7 @@ if [ "$1" = "--le-auto-phase2" ]; then echo "Installing Python packages..." TEMP_DIR=$(TempDir) + trap "rm -rf $TEMP_DIR" EXIT # There is no $ interpolation due to quotes on starting heredoc delimiter. # ------------------------------------------------------------------------- cat << "UNLIKELY_EOF" > "$TEMP_DIR/setuptools-requirements.txt" @@ -1666,7 +1666,6 @@ UNLIKELY_EOF # ------------------------------------------------------------------------- InstallRequirements "setuptools-requirements.txt" InstallRequirements "letsencrypt-auto-requirements.txt" - rm -rf "$TEMP_DIR" echo "Installation succeeded." fi echo "Requesting root privileges to run letsencrypt..." diff --git a/letsencrypt-auto-source/letsencrypt-auto.template b/letsencrypt-auto-source/letsencrypt-auto.template index 4b716064b7e..3b3cd2a2df9 100755 --- a/letsencrypt-auto-source/letsencrypt-auto.template +++ b/letsencrypt-auto-source/letsencrypt-auto.template @@ -179,7 +179,6 @@ InstallRequirements() { echo "Had a problem while downloading and verifying Python packages:" echo "$PEEP_OUT" rm -rf "$VENV_PATH" - rm -rf "$TEMP_DIR" exit 1 fi } @@ -206,6 +205,7 @@ if [ "$1" = "--le-auto-phase2" ]; then echo "Installing Python packages..." TEMP_DIR=$(TempDir) + trap "rm -rf $TEMP_DIR" EXIT # There is no $ interpolation due to quotes on starting heredoc delimiter. # ------------------------------------------------------------------------- cat << "UNLIKELY_EOF" > "$TEMP_DIR/setuptools-requirements.txt" @@ -222,7 +222,6 @@ UNLIKELY_EOF # ------------------------------------------------------------------------- InstallRequirements "setuptools-requirements.txt" InstallRequirements "letsencrypt-auto-requirements.txt" - rm -rf "$TEMP_DIR" echo "Installation succeeded." fi echo "Requesting root privileges to run letsencrypt..."