#! /bin/sh

if sd_booted; then
	# Nothing to do, adding Cups-PDF will be handled by cups-pdf-firsttime.service
	exit 0
fi

service cups status > /dev/null 2>&1
CUPSRUNNING=$?

if [ $CUPSRUNNING -ne 0 ]; then
   service cups start > /dev/null 2>&1
fi

/usr/sbin/lpadmin -p Cups-PDF -v cups-pdf:/ -m CUPS-PDF.ppd -E > /dev/null 2>&1 || :
/usr/sbin/lpadmin -d Cups-PDF > /dev/null 2>&1 || :

if [ $CUPSRUNNING -ne 0 ]; then
   service cups stop > /dev/null 2>&1 || :
fi
