From 76ba2b407a7ab13fd476bcbc059b61a0a7c5a311 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 1 Jun 2024 21:47:08 -0700 Subject: [PATCH] feat: RESET_PIPELINES_DIR env var --- start.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/start.sh b/start.sh index bc21188..9b71a22 100755 --- a/start.sh +++ b/start.sh @@ -1,6 +1,33 @@ #!/usr/bin/env bash PORT="${PORT:-9099}" HOST="${HOST:-0.0.0.0}" +# Default value for PIPELINES_DIR +PIPELINES_DIR=${PIPELINES_DIR:-./pipelines} + +# Function to reset pipelines +reset_pipelines_dir() { + if [ "$RESET_PIPELINES_DIR" = true ]; then + echo "Resetting pipelines directory: $PIPELINES_DIR" + + # Check if the directory exists + if [ -d "$PIPELINES_DIR" ]; then + # Remove all contents of the directory + rm -rf "${PIPELINES_DIR:?}"/* + echo "All contents in $PIPELINES_DIR have been removed." + + # Optionally recreate the directory if needed + mkdir -p "$PIPELINES_DIR" + echo "$PIPELINES_DIR has been recreated." + else + echo "Directory $PIPELINES_DIR does not exist. No action taken." + fi + else + echo "RESET_PIPELINES_DIR is not set to true. No action taken." + fi +} + +# Example usage of the function +reset_pipelines_dir # Function to install requirements if requirements.txt is provided install_requirements() {