#!/bin/bash
# -*- mode: shell-script; coding: utf-8 -*-
#
# Copyright 2008-2014 Cendio AB.
# For more information, see http://www.cendio.com

[ -h "$0" ] && ORIGIN=`ls -l "$0" | sed "s/.*-> //g"` || ORIGIN="$0"
ORIGIN=`(cd "\`dirname \"$ORIGIN\"\`"; pwd -P 2>/dev/null || pwd)`

#
# Gather paths
#
if [ -z "${CUPS_PREFIX}" ]; then
    CUPS_PREFIX="/usr"
    echo "CUPS_PREFIX not defined; using ${CUPS_PREFIX}"
else
    echo "Using CUPS installed at prefix ${CUPS_PREFIX}"
fi

if [ -z "${CUPS_SERVERBIN}" ]; then
    CUPS_SERVERBIN="${CUPS_PREFIX}/lib/cups"
    echo "CUPS_SERVERBIN not defined; using ${CUPS_SERVERBIN}"
else
    echo "Using CUPS_SERVERBIN=${CUPS_SERVERBIN}"
fi

cups_config_dir="/etc/cups"
cups_filter_dir="${CUPS_SERVERBIN}/filter"

for filter in thinlinc-ps2pdf; do
    rm -f ${cups_filter_dir}/${filter}
    rm -f ${cups_config_dir}/${filter}.convs
done

#
# Restart CUPS
#
${ORIGIN}/restart_cups
if [ $? -ne 0 ]; then
    exit 1
fi

