#!/bin/bash

set -e

. /usr/share/dosis2/bin/shell-support-functions


SPOOLER_DIR="/var/spool/cups/."

if [[ -d ${SPOOLER_DIR} ]]; then
        if [ "`getos`" = "CentOS" ]; then
                /sbin/service dosis_extprint stop
                /sbin/service cups stop
                /usr/sbin/tmpwatch -f --ctime 10d "${SPOOLER_DIR}"
                /usr/sbin/tmpwatch -f --mtime 10d "${SPOOLER_DIR}"
                /sbin/service cups start
                sleep 5
                /sbin/service dosis_extprint restart
        elif [ "`getos`" = "Ubuntu" ]; then
                /bin/systemctl stop dosis-extprint
                /bin/systemctl stop cups
                /usr/sbin/tmpreaper -f --ctime 10d "${SPOOLER_DIR}"
                /usr/sbin/tmpreaper -f --mtime 10d "${SPOOLER_DIR}"
                /bin/systemctl start cups
                sleep 5
                /bin/systemctl start dosis-extprint
        else
                abort 1 "Unknown Operating System"
        fi
fi



