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