#!/bin/sh

set -eu

test_nginx() {
    STATUS_SKIP=77

    netstat --tcp -lnp | grep nginx | grep 80

    if [ "$?" != 0 ]; then
        echo "nginx is not listening at port TCP/80"
        echo "ending $0 with status $STATUS_SKIP"
        exit $STATUS_SKIP
    fi
}

web_test() {
    PSFILE="$AUTOPKGTEST_TMP/out.ps"

    html2ps http://localhost > $PSFILE 2>/dev/null

    if [ ! -s "$PSFILE" ]; then
        echo "ERROR on creating $PSFILE."
        exit 1
    fi
}

test_nginx
web_test

exit 0
