#!/bin/bash

. ${TOOLKIT}-functions.sh


cd /etc/cups/ssl

certfile=`jtconf cert.filename` || exit_missing_define cert.filename

# se installato modulo srv-ssl uso certificati corretti,
# altrimenti ripiego su default (es: e` un client e non
# ha il apache e quindi il modulo srv-ssl installato)
#
[ -f /etc/sll/certs/$certfile.pem ] || {
	certfile="ssl-cert-snakeoil"
	echo "  no srv-ssl module, using $certfile as certfile"
}

updatelink /etc/ssl/certs/$certfile.pem   server.crt
updatelink /etc/ssl/private/$certfile.key server.key


# print-to-pdf-file backend
#
[ -x backend-pdf/install ] && backend-pdf/install


# cope with cups server random disabling printers (eg: wifi ones)
#
file="ku-cups-reenable-printers.cron"
dest="/etc/cron.d/ku-cups-reenble-printers"

if getconfirm cups_disable_fix.enabled
then
	echo "  cups_disable_fix cronjob: ENABLED"
	installfile $file $dest		root:root 444
else
	echo "  cups_disable_fix cronjob: disabled"
	uninstallfiles $dest $cmddest
fi


$SOMETHING_CHANGED && {
	restart_service cups cupsd || exit 1
}
exit 0
