-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdaemon.sh
executable file
·46 lines (41 loc) · 1.12 KB
/
daemon.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
trap _cleanup EXIT
function _cleanup() {
kill $_pid
}
make html
python -m http.server -d build/html &
_pid=$!
echo "Press Ctrl-c to exit"
# if [ "$(uname)" == "Darwin" ]; then
# elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
# elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
# fi
watcher() {
buildsum1=""
sourcesum1=""
while [[ true ]]
do
sourcesum2=`find source -type f -exec md5sum {} \;`
if [[ $sourcesum1 != $sourcesum2 ]] ; then
if [ -n "$sourcesum1" ]; then
echo "Rebuilding assets"
make html
fi
sourcesum1=$sourcesum2
fi
buildsum2=`find build/html -type f -exec md5sum {} \;`
if [[ $buildsum1 != $buildsum2 ]] ; then
if [ -n "$buildsum1" ]; then
kill $_pid
echo "Restarting developer server"
python -m http.server -d build/html &
_pid=$!
fi
buildsum1=$buildsum2
fi
sleep 2
done
}
watcher