From be116c222e13950d8fb7afef390a80633a882269 Mon Sep 17 00:00:00 2001 From: Jali Date: Sun, 21 Sep 2025 00:36:31 +0200 Subject: [PATCH] Fix bugs in service script - Call initialize_repos - only call .git-monitor_after.sh only if it exists --- services/git-monitor | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/git-monitor b/services/git-monitor index 7b37016..40d0047 100755 --- a/services/git-monitor +++ b/services/git-monitor @@ -41,8 +41,8 @@ run_after() { initialize_repos() { while read -r REPO_NAME REPO_URL; do if [ ! -d "$REPO_LOCAL_PATH/$REPO_NAME" ]; then - log_message "INFO" "Repository directory does not exist. Cloning..." - mkdir -p "$REPO_LOCAL_PATH" + log_message "INFO" "Repository directory $REPO_LOCAL_PATH/$REOP_NAME does not exist. Cloning..." + mkdir -p "$REPO_LOCAL_PATH/$REPO_NAME" git clone --depth 1 "$REPO_URL" "$REPO_LOCAL_PATH/$REPO_NAME" if [ $? -ne 0 ]; then log_message "ERROR" "Failed to clone repository. Exiting." @@ -88,12 +88,14 @@ create_lock log_message "INFO" "Git monitor started." -initialize_repo +initialize_repos while true; do while read -r $REPO_NAME $REPO_URL; do check_for_updates $REPO_NAME - run_after "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh" + if [ -f "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh" ]; then + run_after "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh" + fi done < $REPO_URLS sleep "$POLL_INTERVAL" done