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
|
#!/bin/sh
# version 20221215
# generic test that only verifies that nginx is running with the given
# libnginx-... module
# - after installation
# - after nginx reload
# - after nginx restart
EX=0
CURL_CMD="curl --max-time 60 --silent --fail -o /dev/null"
#change directory to $AUTOPKGTEST_TMP
cd "${AUTOPKGTEST_TMP}"
echo -n "curl after installation: http status="
if $CURL_CMD -w "response_code: %{http_code}, ... " http://127.0.0.1/; then
echo "OK"
else
EX=1
echo "FAILED"
fi
echo -n "nginx reload ... "
if invoke-rc.d nginx reload; then
echo "OK"
else
EX=1
echo "FAILED"
fi
sleep 5
echo -n "curl after reload: http status="
if $CURL_CMD -w "response_code: %{http_code}, ... " http://127.0.0.1/; then
echo "OK"
else
EX=1
echo "FAILED"
fi
echo -n "nginx restart ... "
if invoke-rc.d nginx restart; then
echo "OK"
else
EX=1
echo "FAILED"
fi
sleep 5
echo -n "curl after restart: http status="
if $CURL_CMD -w "response_code: %{http_code}, ... " http://127.0.0.1/; then
echo "OK"
else
EX=1
echo "FAILED"
fi
if [ ${EX} -ne 0 ]; then
echo "=== journalctl ==="
journalctl -n all -xu nginx.service || :
echo "=== error.log ==="
if [ `wc -l /var/log/nginx/error.log | cut -d ' ' -f1` -gt 100 ]; then
head -n 50 /var/log/nginx/error.log
echo '...'
tail -n 50 /var/log/nginx/error.log
else
cat /var/log/nginx/error.log
fi
fi
exit ${EX}
|