aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/build-site.sh
blob: c5b8331f37534495b8e6145e7bb8e20277343d99 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

ROOT=/var/www/time.mattrude.com
POOLPAGE=$ROOT/status
TEMPLATESDIR=$ROOT/scripts/templates
DOCUMENTSDIR=$ROOT/documentation


### Building the README Page ###

cd $ROOT
rm -rf $ROOT/readme.tmp $TEMPLATESDIR/readme.html $ROOT/tmp
mkdir -p $ROOT/tmp
chown apache:apache $ROOT/tmp
markdown $ROOT/README.md > $ROOT/readme.tmp
cat $TEMPLATESDIR/head > $DOCUMENTSDIR/readme.html
echo "                <div id='title'>
                        <h1>time.mattrude.com <i>&mdash; Readme File</i></h1>
                </div>
                <p> <a href='/'>time.mattrude.com</a> / <a href='/documentation/'>documentation</a> / <strong>readme</strong> / </p>" >> $DOCUMENTSDIR/readme.html
cat $ROOT/readme.tmp $TEMPLATESDIR/tail >> $DOCUMENTSDIR/readme.html
rm -f $ROOT/readme.tmp

### Building per host cgi files ###

mkdir -p $ROOT/bin $ROOT/tmp
for X in `cat $ROOT/rrd/list-of-systems`
do
	rm -f $ROOT/bin/graphs-$X.cgi
        sed -e s/POOL/$X/g $TEMPLATESDIR/graphs.cgi > $ROOT/bin/graphs-$X.cgi
	chmod 755 $ROOT/bin/graphs-$X.cgi
done

### Building the Status Pages ###
mkdir -p $POOLPAGE
cd $POOLPAGE
cat /dev/null > out.template

echo "<h2>Time Server Hosts</h2>
<ul>" >> out.template
for X in `cat $ROOT/rrd/list-of-systems`
do
	echo "<li><a href='/status/$X/'>$X</a></li>" >> out.template
done
echo "</ul>" >> out.template

for X in `cat /var/www/time.mattrude.com/rrd/list-of-systems`
do
	sed -e s/POOL/$X/g $TEMPLATESDIR/template >> out.template
done

sync
cat $TEMPLATESDIR/index-head out.template $TEMPLATESDIR/tail > $POOLPAGE/index.html

# Build the indexs for the hosts.
for X in `cat /var/www/time.mattrude.com/rrd/list-of-systems`
do
	mkdir -p $POOLPAGE/$X
	cat /dev/null > out.template
        sed -e s/POOL/$X/g $TEMPLATESDIR/template-host >> out.template
	sync
	cat out.template $TEMPLATESDIR/tail > $X/index.html
	rm -f out.template
	for a in clients offset jitter freq sjit cjit wander disp
	do
		mkdir -p $POOLPAGE/$X/$a
		cat /dev/null > out.template
		sed -e s/POOL/$X/g $TEMPLATESDIR/template-host-by-type |sed -e s/###TYPE###/$a/g >> out.template
	        sync
	        cat out.template $TEMPLATESDIR/tail > $X/$a/index.html
	        rm -f out.template
	done
done
chown -R apache:apache $POOLPAGE