#!/bin/sh -e
#
# Test if the CUPS server is working.

if [ -f /etc/cups/cupsd.conf ] ; then
    :
else
    echo "error: $0: /etc/cups/cupsd.conf is missing.  Is cupsys installed?"
    exit 1
fi

if pidof cupsd > /dev/null ; then
    echo "success: $0: cupsd is running."
else
    echo "error: $0: cupsd is not running."
    exit 1
fi

port=ipp
proto=tcp

if netstat -a 2>&1 | grep ":$port " | grep -q "^$proto" ; then
    echo "success: $0: cupsd server is listening on $port/$proto."
else
    echo "error: $0: cupsd server is not listening on $port/$proto."
    exit 1
fi

exit 0
