#!/bin/bash set -e # Load configuration CONFIG_FILE="${CONFIG_FILE:-config.local.env}" if [ ! -f "$CONFIG_FILE" ]; then CONFIG_FILE="config.env" fi if [ ! -f "$CONFIG_FILE" ]; then echo "ERROR: Configuration file not found. Please create config.local.env or config.env" exit 1 fi # shellcheck disable=SC1090 source "$CONFIG_FILE" echo "Checking drift between git repo and live server..." echo " Comparing: $GIT_RSYSLOG_MAIN_CONFIG ↔ $RSYSLOG_MAIN_CONFIG" echo " Comparing: $GIT_RSYSLOG_CONFIG_DIR ↔ $RSYSLOG_CONFIG_DIR" DIFF_FOUND=0 echo echo "Comparing $RSYSLOG_MAIN_CONFIG" if ! diff -u "$GIT_RSYSLOG_MAIN_CONFIG" "$RSYSLOG_MAIN_CONFIG"; then DIFF_FOUND=1 fi echo echo "Comparing $RSYSLOG_CONFIG_DIR configs" for file in "$GIT_RSYSLOG_CONFIG_DIR"/*.conf; do base=$(basename "$file") target="$RSYSLOG_CONFIG_DIR/$base" if [ ! -f "$target" ]; then echo "Missing on server: $target" DIFF_FOUND=1 continue fi if ! diff -u "$file" "$target"; then DIFF_FOUND=1 fi done if [ "$DIFF_FOUND" -eq 0 ]; then echo echo "No drift detected." exit 0 else echo echo "Drift detected!" exit 1 fi