Release v.1.0.25270.1 #1

Merged
jali merged 26 commits from develop into main 2025-09-27 19:36:19 +00:00
Showing only changes of commit ea1e22d3e4 - Show all commits

View File

@@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# Configuration (Customize these!) # Configuration (Customize these!)
REPO_URL="ssh://gitea@git.orca-central.de:10229/jali/PDP10Sudoku.git" REPO_URLS="/opt/src/repository.list"
REPO_LOCAL_PATH="/home/jali/Projects/PDP10Sudoku" REPO_LOCAL_PATH="/opt/src"
BRANCH_NAME="develop" BRANCH_NAME="develop"
POLL_INTERVAL=60 # Seconds between checks POLL_INTERVAL=60 # Seconds between checks
#LOG_FILE="/var/log/git-monitor.log" # Log file for recording actions #LOG_FILE="/var/log/git-monitor.log" # Log file for recording actions
@@ -32,41 +32,49 @@ remove_lock() {
rm -f "$LOCK_FILE" rm -f "$LOCK_FILE"
} }
initialize_repo() { run_after() {
if [ ! -d "$REPO_LOCAL_PATH" ]; then local after_pull_script=$1
source $after_pull_script
}
initialize_repos() {
while IFS=: read -r REPO_NAME REPO_URL; do
if [ ! -d "$REPO_LOCAL_PATH/$REPO_NAME" ]; then
log_message "INFO" "Repository directory does not exist. Cloning..." log_message "INFO" "Repository directory does not exist. Cloning..."
mkdir -p "$REPO_LOCAL_PATH" mkdir -p "$REPO_LOCAL_PATH"
git clone --depth 1 "$REPO_URL" "$REPO_LOCAL_PATH" 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."
exit 1 exit 1
fi fi
log_message "INFO" "Repository cloned successfully." log_message "INFO" "Repository cloned successfully."
fi fi
done <$REPO_URLS
} }
check_for_updates() { check_for_updates() {
local repo_name=$1
local last_commit_hash local last_commit_hash
local current_commit_hash local current_commit_hash
# Get the last known commit hash (from a file) # Get the last known commit hash (from a file)
if [ -f "$REPO_LOCAL_PATH/.git-monitor-last-commit" ]; then if [ -f "$REPO_LOCAL_PATH/$repo_name/.git-monitor-last-commit" ]; then
last_commit_hash=$(cat "$REPO_LOCAL_PATH/.git-monitor-last-commit") last_commit_hash=$(cat "$REPO_LOCAL_PATH/$repo_name/.git-monitor-last-commit")
else else
last_commit_hash="" # Initialize if file doesn't exist last_commit_hash="" # Initialize if file doesn't exist
fi fi
# Fetch the latest commit hash from the remote repository # Fetch the latest commit hash from the remote repository
current_commit_hash=$(git -C "$REPO_LOCAL_PATH" branch --format '%(sha)') current_commit_hash=$(git -C "$REPO_LOCAL_PATH/$repo_name" branch --format '%(sha)')
if [ -z "$last_commit_hash" ] || [ "$current_commit_hash" != "$last_commit_hash" ]; then if [ -z "$last_commit_hash" ] || [ "$current_commit_hash" != "$last_commit_hash" ]; then
log_message "INFO" "New commits detected. Pulling..." log_message "INFO" "New commits detected. Pulling..."
git -C "$REPO_LOCAL_PATH" pull origin "$BRANCH_NAME" git -C "$REPO_LOCAL_PATH/$repo_name" pull origin "$BRANCH_NAME"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
log_message "INFO" "Pull successful." log_message "INFO" "Pull successful."
# Update the last commit hash file # Update the last commit hash file
echo "$current_commit_hash" > "$REPO_LOCAL_PATH/.git-monitor-last-commit" echo "$current_commit_hash" > "$REPO_LOCAL_PATH/$repo_name/.git-monitor-last-commit"
else else
log_message "ERROR" "Pull failed." log_message "ERROR" "Pull failed."
fi fi
@@ -82,7 +90,10 @@ log_message "INFO" "Git monitor started."
initialize_repo initialize_repo
while true; do while true; do
check_for_updates while IFS=: read -r $REPO_NAME $REPO_URL; do
check_for_updates $REPO_NAME
run_after "$REPO_LOCAL_PATH/$REPO_NAME/.git-monitor_after.sh"
done < $REPO_URLS
sleep "$POLL_INTERVAL" sleep "$POLL_INTERVAL"
done done