#!/bin/sh
set -e

# Automatically added by dh_installdocs
if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/pwrtest ]; then
        rm -f /usr/doc/pwrtest
fi
# End automatically added section

proot="/pwrp"
aroot="/usr/pwrp/adm"

echo ""
echo -n "Do you wan't to remove project (y/n) [n] "
read remove_all

if [ "$remove_all" = "y" ]; then
  
  echo "-- Remove project $proot"
  if [ -e $proot ]; then
    rm -r $proot
  fi

  if [ -e $aroot ]; then
    rm -r $aroot
  fi
fi

# Remove startup
if [ -e /etc/rc2.d/S90pwr ]; then
  rm /etc/rc2.d/S90pwr
fi

# Remove jar-files on web directory
if [ -e /etc/proview.cnf ]; then
  web_dir=`eval cat /etc/proview.cnf | grep "\\bwebDirectory\\b" | awk '{print $2}'`

  if [ -e $web_dir/pwr_rt_client.jar ]; then
    rm $web_dir/pwr_rt_client.jar
  fi
  if [ -e $web_dir/pwr_jop.jar ]; then
    rm $web_dir/pwr_jop.jar
  fi
fi
