From fa622ad30bad87c46bbe8f101dda0c1ad9b0bc0d Mon Sep 17 00:00:00 2001 From: Satyam Date: Sun, 16 Feb 2025 10:29:04 +0530 Subject: [PATCH] Add conditional directory/file handling for source and target --- entrypoint.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index d8a5772..3149c4b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -102,22 +102,26 @@ TEMP_DIR=$(mktemp -d) # including "." and with the exception of ".git/" mv "$CLONE_DIR/.git" "$TEMP_DIR/.git" -# $TARGET_DIRECTORY is '' by default -ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/" +# check if sourcefile and target file is not set +if [ -z "$SOURCE_FILE" ] && [ -z "$TARGET_FILE" ] +then + # $TARGET_DIRECTORY is '' by default + ABSOLUTE_TARGET_DIRECTORY="$CLONE_DIR/$TARGET_DIRECTORY/" -echo "[+] Deleting $ABSOLUTE_TARGET_DIRECTORY" -rm -rf "$ABSOLUTE_TARGET_DIRECTORY" + echo "[+] Deleting $ABSOLUTE_TARGET_DIRECTORY" + rm -rf "$ABSOLUTE_TARGET_DIRECTORY" -echo "[+] Creating (now empty) $ABSOLUTE_TARGET_DIRECTORY" -mkdir -p "$ABSOLUTE_TARGET_DIRECTORY" + echo "[+] Creating (now empty) $ABSOLUTE_TARGET_DIRECTORY" + mkdir -p "$ABSOLUTE_TARGET_DIRECTORY" -echo "[+] Listing Current Directory Location" -ls -al + echo "[+] Listing Current Directory Location" + ls -al -echo "[+] Listing root Location" -ls -al / + echo "[+] Listing root Location" + ls -al / -mv "$TEMP_DIR/.git" "$CLONE_DIR/.git" + mv "$TEMP_DIR/.git" "$CLONE_DIR/.git" +fi # if source directory is set if [ -n "$SOURCE_DIRECTORY" ]