#!/bin/sh
# postinst script for recovery-tools
#
# by Luigi Cotignano
# http://n900.altervista.org

case "$1" in
     configure)
	echo "Installing TestDisk and PhotoRec..."

	echo "Updating Sudoers..."
	update-sudoers || true
	
	echo "Creating symlinks..."
	if [ ! -h /usr/bin/photorec ];
	then
	    ln -s /opt/recovery-tools/photorec /usr/bin/photorec
	fi

	if [ ! -h /usr/bin/testdisk ];
	then
	    ln -s /opt/recovery-tools/testdisk /usr/bin/testdisk
	fi

	if [ ! -f /opt/recovery-tools/photorec ];
	then
	    echo "Restoring PhotoRec..."
	    cp /opt/recovery-tools/photorec_backup /opt/recovery-tools/photorec
	fi

	if [ ! -f /opt/recovery-tools/testdisk ];
	then
	    echo "Restoring TestDisk..."
	    cp /opt/recovery-tools/testdisk_backup /opt/recovery-tools/testdisk
	fi
	
	rm -f /opt/recovery-tools/*_backup

	if [ -x /usr/bin/gtk-update-icon-cache ]; then
	  gtk-update-icon-cache -f /usr/share/icons/hicolor || true
	fi	

	echo "TestDisk and PhotoRec has been installed successfully."
	exit 0
	;;

     abort-upgrade|abort-remove|abort-deconfigure)
    	;;

     *)
	echo "Error: unable to install TestDisk and PhotoRec, postinst called with unknown argument \`$1'" >&2
	exit 1
	;;
esac

	# dh_installdeb will replace this with shell code automatically
	# generated by other debhelper scripts.
exit 0


