#!/bin/bash
#
# Turboprint deinstallation script
#
# must have root permissions
#

# get dirs

if [ ! -e /etc/turboprint/system.cfg ] ; then
	echo "Configuration file "etc/turboprint/system.cfg" not found!"
	exit 1
fi

eval $(cat /etc/turboprint/system.cfg)

echo
echo "Turboprint deinstallation"
echo "========================="
echo "Will delete the following directories:"
echo "$TPPATH_CONFIG"
echo "$TPPATH_SHARE"
echo
echo "And the following files:"
echo "$TPPATH_BIN/tpprint"
echo "$TPPATH_BIN/tpsetup"
echo "$TPPATH_BIN/xtpsetup"
echo "$TPPATH_BIN/tpconfig"
echo "$TPPATH_BIN/xtpconfig"
echo "$TPPATH_BIN/turboprint"
echo "$TPPATH_MAN/man1/tpprint.1"
echo "$TPPATH_MAN/man1/tpsetup.1"
echo "$TPPATH_MAN/man1/tpconfig.1"
echo "$TPPATH_MAN/man7/tpfilter.7"
echo "$TPPATH_MAN/man7/turboprint.7"
echo "$TPPATH_LOG/turboprint.log"
echo "$TPPATH_LOG/turboprint_lpr.log"
echo "$TPPATH_LOG/turboprint_cups.log"
if [ -e "$TPPATH_CUPSDRIVER/turboprint" ] ; then
	echo "$TPPATH_CUPSDRIVER/turboprint"
fi
echo
echo -n "Start deinstallation now? "
read ANSWER

if [ -z $ANSWER ] ; then
	exit 0
fi
if [ $ANSWER != "y" ] ; then
	exit 0
fi

# call script to remove dynamic data (also called by rpm %preun)

lib/uninstall-pre

# call script to remove static files

lib/uninstall-static --tgz

echo "Deinstallation complete"

exit 0
