-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocalDevWatcher.sh
executable file
·31 lines (28 loc) · 1.14 KB
/
localDevWatcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
echo "DISABLED"
exit 1
lastChangeToSourceDirFile="/tmp/carleton_dev_syncer.txt"
let delayThreshold=1000 # number of ms we want to wait before kicking off an rsync
sleepAmount=".1"
if [ "${1}" == "copy" ]; then
echo "Checking monitor file... (start with no arguments to run in watch mode)"
while true; do
if [ -e "${lastChangeToSourceDirFile}" ]; then
currentTime=`gdate +%s%N | cut -b1-13`
lastMarkedTime=`cat ${lastChangeToSourceDirFile}`
let timeElapsed=${currentTime}-${lastMarkedTime}
echo "[${timeElapsed}] ms elapsed since file was updated..."
if [ ${timeElapsed} -gt ${delayThreshold} ]; then
rm "${lastChangeToSourceDirFile}"
cd ~/development/carleton/
echo "Starting rsync (`date`)..."
rsync -r -q --exclude ".git" --exclude ".swp" --delete carleton.edu/ tfeiler@wsgdev05.its.carleton.edu:/var/www/apps/
echo "done! (`date`)"
fi
fi
sleep "${sleepAmount}"
done
else
echo "Watching source directory (start with 'copy' arg to run in alternate mode)"
fswatch -o -0 ~/development/carleton/carleton.edu | xargs -0 -I {} -P 100 -n 1 sh -c 'gdate +%s%N | cut -b1-13 > /tmp/carleton_dev_syncer.txt' --
fi