-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_html.sh
executable file
·61 lines (45 loc) · 1.24 KB
/
build_html.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Stolen from http://grepalex.com/2012/08/17/full-jekyll-VM-setup/
# with some obvious modifications
send_email_and_exit() {
recipient=$1
message=$2
echo "Sending email and exiting due to error"
/bin/mail -s "Blog generation failure" "${recipient}" << EOF
${message}
EOF
exit 1
}
echo "========== Running at `date` =========="
basedir=/home/sandy/github
gitdir=${basedir}/blog
nginxdir=/usr/share/nginx/www
stagingdir=$(mktemp)
githubrepo=https://github.com/jswu/blog.git
emailto="[email protected]"
if [ ! -d ${gitdir} ]; then
echo "Checking out repo for the first time"
mkdir -p ${gitdir}
cd ${basedir}
git clone ${githubrepo}
else
cd ${gitdir}
git pull
fi
# TODO: Generalize this
(cd ${nginxdir} && rm -rf `ls | grep -v "^tmp$" | grep -v "^event-journal$"`)
cd ${gitdir}
# Rebuild CSS
compass compile conf
jekyll build --destination ${stagingdir}/
cp -r ${stagingdir}/* ${nginxdir}/
echo "Final destination: ${nginxdir}"
exitCode=$?
if [ ${exitCode} != "0" ]; then
send_email_and_exit "${emailto}" "Jekyll failed with exit code ${exitCode}"
fi
curl http://0.0.0.0:80/ >/dev/null 2>&1
exitCode=$?
if [ ${exitCode} != "0" ]; then
send_email_and_exit "${emailto}" "Curl failed with exit code ${exitCode}"
fi