Watches /opt/strshipos for file changes via inotifywait, debounces 10s, then commits and pushes to both origin and starshipos remotes. Runs as a systemd service (strshipos-autocommit). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 lines
996 B
Bash
Executable File
33 lines
996 B
Bash
Executable File
#!/bin/bash
|
|
# Watch /opt/strshipos for changes and auto-commit+push to Gitea
|
|
|
|
REPO="/opt/strshipos"
|
|
DEBOUNCE=10 # seconds to wait after last change before committing
|
|
|
|
cd "$REPO"
|
|
|
|
inotifywait -m -r -e close_write,create,delete,move \
|
|
--exclude '(\.git|data/|/logs/)' \
|
|
"$REPO" 2>/dev/null | while read -r dir event file; do
|
|
|
|
# Reset debounce timer
|
|
touch /tmp/strshipos-pending-commit
|
|
|
|
# Wait for quiet period
|
|
(
|
|
sleep $DEBOUNCE
|
|
# Only proceed if we're still the latest trigger
|
|
if [ -f /tmp/strshipos-pending-commit ]; then
|
|
rm -f /tmp/strshipos-pending-commit
|
|
cd "$REPO"
|
|
git add docker-compose.yml logo.svg favicon.svg favicon16.png favicon144.png \
|
|
xwiki-org/cssVariablesInit.min.css xwiki-com/cssVariablesInit.min.css .gitignore
|
|
if ! git diff --cached --quiet; then
|
|
git commit -m "auto: backup config changes $(date '+%Y-%m-%d %H:%M:%S')"
|
|
git push origin master
|
|
git push starshipos master
|
|
fi
|
|
fi
|
|
) &
|
|
done
|