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
|
#!/bin/sh
ZIPROXY_TCP_PORT=8080
STATUS_ERROR=1
STATUS_SKIP=77
test_apache() {
netstat --tcp -lnp | grep apache | grep 80
if [ "$?" != 0 ]; then
echo "apache2 is not listening at port TCP/80"
echo "ending $0 with status $STATUS_SKIP"
exit $STATUS_SKIP
fi
}
test_wget() {
wget -q -O /dev/null -4 localhost:80
if [ "$?" != 0 ]; then
echo "wget on localhost:80 failed"
echo "ending $0 with status $STATUS_SKIP"
exit $STATUS_SKIP
fi
}
test_ziproxy() {
netstat --tcp -lnp | grep ziproxy | grep $ZIPROXY_TCP_PORT
if [ "$?" != 0 ]; then
echo "Ziproxy is not listening at port TCP/$ZIPROXY_TCP_PORT"
echo "ending $0 with status $STATUS_ERROR"
exit $STATUS_ERROR
fi
}
test_request_over_ziproxy() {
MAXTRY=5
itry=0
while [ $itry -lt $MAXTRY ]; do
http_proxy=localhost:$ZIPROXY_TCP_PORT wget -q -O /dev/null \
-4 localhost:80 && break
itry=`expr $itry + 1`
sleep 1
done
if [ "$itry" -eq "$MAXTRY" ]; then
echo "requests to Ziproxy on port TCP/$ZIPROXY_TCP_PORT failed $MAXTRY times"
echo "ending $0 with status $STATUS_ERROR"
exit $STATUS_ERROR
fi
}
## main
test_apache
test_wget
test_ziproxy
test_request_over_ziproxy
exit 0
|