From 0d908159c157126eef46473ca58acfedb9c068a2 Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Mon, 27 Mar 2023 10:34:22 +0400 Subject: [PATCH] Update update-restic.sh to use a temporary directory for cloning and cleanup - Modify the script to create a unique temporary directory for cloning the repository - Change the script to remove the temporary directory after execution - Ensure the repository is cloned into the temporary directory and cleaned up after the script is done running --- update-restic.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/update-restic.sh b/update-restic.sh index 38598ca..673e180 100644 --- a/update-restic.sh +++ b/update-restic.sh @@ -18,9 +18,10 @@ if ! grep -q "^relayhost" $POSTFIX_CONFIG; then exit 1 fi -# Clone the repository -git clone $GIT_REPO -cd restic-docker +# Create a temporary directory and clone the repository +TEMP_DIR=$(mktemp -d) +git clone $GIT_REPO $TEMP_DIR +cd $TEMP_DIR # Get the latest version of Restic LATEST_VERSION=$(curl --silent "https://api.github.com/repos/restic/restic/releases/latest" | jq -r .tag_name | tr -d v) @@ -46,3 +47,7 @@ if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then else echo "The Restic Docker image is already up to date (version $CURRENT_VERSION)." fi + +# Clean up the temporary directory +cd .. +rm -rf $TEMP_DIR \ No newline at end of file