#! /bin/sh

# Completely remove a Pathena installation including the current
# database and PostgreSQL cluster.

# Home directory for Pathena files is changed in this script
# by invoking script 'build/relocate'.

export PATHENA=~/.pathena


echo -n "You have asked to remove the Pathena installation.
Do you really want to uninstall? "

answer=timeout

read -t 60 answer

case $answer in
  y|Y|yes|Yes|YES)
     echo "OK, proceeding to uninstall Pathena."
     ;;
  timeout)
     echo "
No response.  Pathena will not be removed."
     exit 0
     ;;
  *)
     echo "OK, Pathena will not be removed."
     exit 0
     ;;
esac


echo "
Deleting all Pathena files based in directory $PATHENA ...
"

# Remove links from ~/bin

if [ $PATHENA/bin/ptfind -ef ~/bin/ptfind ];
     then rm -f ~/bin/ptfind
fi

if [ $PATHENA/bin/launch_client_pytk -ef ~/bin/pathena ];
     then rm -f ~/bin/pathena
fi

# Remove everything from ~/.pathena

rm -rf $PATHENA

echo "... done."
