Fix bugs in service script

- Call initialize_repos
- only call .git-monitor_after.sh only if it exists
This commit is contained in:
2025-09-21 00:36:31 +02:00
parent 2f8b01b768
commit be116c222e

View File

@@ -41,8 +41,8 @@ run_after() {
initialize_repos() { initialize_repos() {
while read -r REPO_NAME REPO_URL; do while read -r REPO_NAME REPO_URL; do
if [ ! -d "$REPO_LOCAL_PATH/$REPO_NAME" ]; then if [ ! -d "$REPO_LOCAL_PATH/$REPO_NAME" ]; then
log_message "INFO" "Repository directory does not exist. Cloning..." log_message "INFO" "Repository directory $REPO_LOCAL_PATH/$REOP_NAME does not exist. Cloning..."
mkdir -p "$REPO_LOCAL_PATH" mkdir -p "$REPO_LOCAL_PATH/$REPO_NAME"
git clone --depth 1 "$REPO_URL" "$REPO_LOCAL_PATH/$REPO_NAME" git clone --depth 1 "$REPO_URL" "$REPO_LOCAL_PATH/$REPO_NAME"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
log_message "ERROR" "Failed to clone repository. Exiting." log_message "ERROR" "Failed to clone repository. Exiting."
@@ -88,12 +88,14 @@ create_lock
log_message "INFO" "Git monitor started." log_message "INFO" "Git monitor started."
initialize_repo initialize_repos
while true; do while true; do
while read -r $REPO_NAME $REPO_URL; do while read -r $REPO_NAME $REPO_URL; do
check_for_updates $REPO_NAME check_for_updates $REPO_NAME
if [ -f "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh" ]; then
run_after "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh" run_after "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh"
fi
done < $REPO_URLS done < $REPO_URLS
sleep "$POLL_INTERVAL" sleep "$POLL_INTERVAL"
done done