Fix bugs in service script
- Call initialize_repos - only call .git-monitor_after.sh only if it exists
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user