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

case "$1" in
     configure)
	echo "Installing TestDisk and PhotoRec for Nokia N900..."
	cd /usr/bin

	echo "Creating TestDisk and PhotoRec symlinks..."
	if [ -h /usr/bin/photorec ];
	then
	   echo "Skipping PhotoRec symlink creation, it's already present.."
	else
	    ln -s /opt/recovery-tools/photorec photorec
	fi

	if [ -h /usr/bin/testdisk ];
	then
	    echo "Skipping TestDisk symlink creation, it's already present.."
	else
	    ln -s /opt/recovery-tools/testdisk testdisk
	fi

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

	if [ -f /opt/recovery-tools/testdisk ];
	then
	    echo ""
	else
	    echo "Restoring TestDisk..."
	    cp /opt/recovery-tools-backup/testdisk /opt/recovery-tools/testdisk
	fi
	
	rm -rf /opt/recovery-tools-backup
	
	echo "TestDisk and PhotoRec for Nokia N900 installed successfully."
	exit 0
	;;

      *)
	echo "Error: unable to install TestDisk and PhotoRec" >&2
	exit 1
	;;
esac

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


