#!/bin/bash # Watch for changes in src/ and auto-deploy to copelk # Run: ./watch-deploy.sh # Stop: Ctrl+C WATCH_DIR="/home/klas/Prace/METRO/web/src" DEPLOY_SCRIPT="/home/klas/Prace/METRO/web/deploy.sh" COOLDOWN=10 echo "Watching $WATCH_DIR for changes..." echo "Auto-deploying to copelk on save" echo "Press Ctrl+C to stop" inotifywait -m -r -e modify,create,delete "$WATCH_DIR" | while read -r dir event file; do echo "" echo "[$(date +%H:%M:%S)] Change detected: $file ($event)" echo "Deploying in ${COOLDOWN}s (waiting for more changes)..." sleep $COOLDOWN # Drain any queued events while read -t 0.1 -r _; do :; done echo "Deploying..." bash "$DEPLOY_SCRIPT" echo "" echo "Watching for next change..." done