diff --git a/apply.sh b/apply.sh new file mode 100755 index 0000000..22d5718 --- /dev/null +++ b/apply.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +echo "Applying rsyslog config from git repo..." + +cp rsyslog.conf /etc/rsyslog.conf +mkdir -p /etc/rsyslog.d +cp rsyslog.d/*.conf /etc/rsyslog.d/ + +echo "Validating config..." +rsyslogd -N1 + +echo "Restarting rsyslog..." +systemctl restart rsyslog + +echo "Done." diff --git a/drift-check.sh b/drift-check.sh new file mode 100755 index 0000000..e30154b --- /dev/null +++ b/drift-check.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +echo "Checking drift between git repo and live server..." + +DIFF_FOUND=0 + +echo +echo "Comparing /etc/rsyslog.conf" +if ! diff -u rsyslog.conf /etc/rsyslog.conf; then + DIFF_FOUND=1 +fi + +echo +echo "Comparing rsyslog.d configs" +for file in rsyslog.d/*.conf; do + base=$(basename "$file") + target="/etc/rsyslog.d/$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