forked from XSCE/xsce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.sh
More file actions
184 lines (160 loc) · 3.76 KB
/
tests.sh
File metadata and controls
184 lines (160 loc) · 3.76 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2; tput bold)
YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
function red() {
echo -e "$RED$*$NORMAL"
}
function green() {
echo -e "$GREEN$*$NORMAL"
}
function yellow() {
echo -e "$YELLOW$*$NORMAL"
}
function ip_range() {
echo -n "[DXS] Test ip range ..."
if `ifconfig | grep -q 172.18`
then
green OK
else
red FAILED!
fi
}
function proxy_presence() {
echo -n "[DXS] Test proxy settings..."
if `curl -Is http://sugardextrose.org/themes/custom/images/sugardextrose.org.png | grep X-Cache | grep -q schoolserver`
then
green OK
else
red FAILED!
fi
echo -n "[DXS] Test proxy caching settings..."
if `curl -Is http://sugardextrose.org/themes/custom/images/sugardextrose.org.png | grep X-Cache | grep schoolserver | grep -q HIT`
then
green OK
else
red FAILED!
fi
}
function dansguardian_presence() {
echo -n "[DXS] Test dansguardian settings..."
if `wget -qO - http://en.wikipedia.org/wiki/Pornography | grep -is dansguardian > /dev/null`
then
green OK
else
red FAILED!
fi
}
function iiab_presence() {
echo -n "[IIAB] Test main iiab page..."
if `curl -Is http://schoolserver.local/iiab/ | grep -is "HTTP/1.1 200 OK" > /dev/null`
then
green OK
else
red FAILED!
fi
echo -n "[IIAB] Test wikipedia page..."
if `curl -Is http://schoolserver.local/iiab/zim/wikipedia_gn_all_01_2013/A/Pirane.html | grep -is "HTTP/1.1 200 OK" > /dev/null`
then
green OK
else
red FAILED!
fi
echo -n "[IIAB] Test khan akademy video..."
if `curl -Is http://schoolserver/iiab/video/khanvideo/1/1/2/3.webm | grep -is "HTTP/1.1 200 OK" > /dev/null`
then
green OK
else
red FAILED!
fi
echo -n "[IIAB] Test map link..."
if `curl -Is http://schoolserver/iiab/maps/tile/6/31/29.png | grep -is "HTTP/1.1 200 OK" > /dev/null`
then
green OK
else
red FAILED!
fi
echo -n "[IIAB] Test book search..."
if `curl -Is http://schoolserver/iiab/books/search?q=moby+dick | grep -is "HTTP/1.1 200 OK" > /dev/null`
then
green OK
else
red FAILED!
fi
echo -n "[IIAB] Test book download..."
if `curl -Is http://schoolserver/iiab/books/epub/2701.epub | grep -is "HTTP/1.1 200 OK" > /dev/null`
then
green OK
else
red FAILED!
fi
}
function dns_client_presence() {
echo -n "[DXS] Test dns client settings..."
if ! [ -x /proc/device-tree/serial-number ]
then
yellow "PASS (Not a client)"
return
fi
IP1=`ping -c1 schoolserver | awk -F" |:" '/from/{print $4}'`
IP2=`ping -c1 schoolserver.local | awk -F" |:" '/from/{print $4}'`
if [ "$IP1" == "$IP2" ] && [ "$IP1" == "172.18.96.1" ]
then
green OK
else
red FAILED!
fi
}
function dns_server_presence() {
echo -n "[DXS] Test dns server settings..."
IP1=`dig +short schoolserver.local @schoolserver`
if [ "$IP1" == "172.18.96.1" ]
then
green OK
else
red FAILED!
fi
}
function test_registration() {
echo -n "[DXS] Test if xo is registered ..."
if ! [ -x /proc/device-tree/serial-number ]
then
yellow "PASS (Not a xo)"
return
fi
SN=`cat /proc/device-tree/serial-number`
PUBKEY=`cat /home/olpc/.sugar/default/owner.key.pub | awk '{print $2}'`
if `wget -qO - http://schoolserver.local:5000/ | grep -is "$SN" > /dev/null` && \
`wget -qO - http://schoolserver.local:5000/ | grep -is "$PUBKEY" > /dev/null`
then
green OK
else
red FAILED!
fi
}
check_env () {
if [ `hostname` == "schoolserver" ]
then
export http_proxy=http://schoolserver:3128
export MODE=server
echo "[DXS] - Running on schoolserver"
else
echo "[DXS] - Running on client"
export MODE=client
fi
}
check_env
ip_range
if [ x"$MODE" == x"server" ]
then
dns_server_presence
else
dns_client_presence
test_registration
fi
proxy_presence
dansguardian_presence
echo
echo "IIAB Tests"
iiab_presence