#!/bin/sh

echo ""
echo "=================================================================="
echo ""
echo "           Communicator4.73[ja] Japanese  Uninstall              "
echo ""
echo "                      ( Super User Only )"
echo "       Copyright (c) 1999 by Netscape Communications Corp."
echo ""
echo "=================================================================="
echo ""
echo ""

case `uname` in
HP-UX)
	ADLOC="/usr/lib/X11/ja_JP.eucJP/app-defaults";
	CFGLOC="/usr/lib/X11/ja_JP.eucJP/app-defaults";
	MISCLOC="/usr/lib/X11/ja_JP.eucJP/netscape";
	;;  
IRIX)
	ADLOC="/usr/lib/X11/ja_JP.EUC/app-defaults";
	CFGLOC="/usr/lib/X11/ja_JP.EUC/app-defaults";
	MISCLOC="/usr/lib/X11/ja_JP.EUC/netscape";
	;;
SunOS)
	ADLOC="/usr/openwin/lib/locale/ja/app-defaults";
	CFGLOC="/usr/openwin/lib/ja/app-defaults";
	MISCLOC="/usr/openwin/lib/locale/ja/netscape";
	;;
AIX)
	ADLOC="/usr/lib/X11/ja_JP/app-defaults";
	CFGLOC="/usr/lib/X11/ja_JP/app-defaults";
	MISCLOC="/usr/lib/X11/ja_JP/netscape";
	;;
FreeBSD|*)
	if [ "x$LANG" = "x" ] ; then
	    LANG=ja_JP.EUC
	fi
	# Location for the apps-default file
	ADLOC="/usr/X11R6/lib/X11/${LANG}/app-defaults";
	# Location for the netscape.cfg file
	CFGLOC="/usr/lib/X11/${LANG}/app-defaults";
	# Location for some Misc pieces
	MISCLOC="/usr/X11R6/lib/X11/${LANG}/netscape";
	;;
esac

echo "Following settings are right for your system?"
echo "If right, type any key to go on."
echo "If not, exit with Ctrl-C and modify this install script to fit your system."
echo ""
echo "	ADLOC   = $ADLOC"
echo "	CFGLOC  = $CFGLOC"
echo "	MISCLOC = $MISCLOC"

read dummy

#
# See if we have to use the lame SYS-V echo command flags.
#
if test "`/bin/echo 'blah\c'`" = "blah\c"
then
        EFLAG="-n"
        ENDER=""
else
        EFLAG=""
        ENDER="\c"
fi
ECHO="/bin/echo ${EFLAG}"

#
# Checking to see if script has been run as root
#
touch /tmp/foo.$$
OWNER="`ls -l /tmp/foo.$$ | awk '{print $3}'`"
rm -f /tmp/foo.$$
if test ! "${OWNER}" = "root"
then
   if test ! "`who am i|awk '{print $1}'`" = "root"
   then
      if test ! "`whoami`" = "root"
      then
         if test ! ${USER} = "root"
         then
            if test ! ${LOGNAME} = "root"
            then
               ${ECHO} "Sorry, you need to be root (super user) to run this script."
               exit 0
            fi
         fi
      fi
   fi
fi

rm -f ${ADLOC}/Netscape
rm -f ${CFGLOC}/netscape.cfg
rm -rf ${MISCLOC}

if test ! -z "${MOZILLA_HOME}" -a -d ${MOZILLA_HOME}/nethelp
then
	INSTALL_DIR="${MOZILLA_HOME}"
else
	if test -d /opt/netscape/nethelp
	then
	    INSTALL_DIR="/opt/netscape"
	else
	    if test -d /usr/local/netscape/nethelp
	    then
		INSTALL_DIR="/usr/local/netscape"
	    fi
	fi
fi

if test -z "${INSTALL_DIR}"
     then
            echo ""
            echo "Sorry, can't find where the Netscape software was installed."
            echo ""
            echo "Please enter the path to your Install Directory:"
            echo ""
            ${ECHO} "[Netscape Install Directory] : ${ENDER}"
            read TARGET
     else
            echo ""
            echo "Please enter the path to your Install Directory."
            echo ""
            echo "Hit return to use the indicated default."
            echo ""
            ${ECHO} "[Install Directory - ${INSTALL_DIR}] : ${ENDER}"
            read TARGET
fi

if test ! -z "${TARGET}"
then
    if test -d ${TARGET}/nethelp
    then
        INSTALL_DIR=${TARGET}
    fi
fi

if test -z "${INSTALL_DIR}"
    then
        echo ""
        echo "Sorry, that doesn't look like the correct location."
        echo ""
        echo "Some localized components can not be uninstalled at this time."
        echo "Re-run this script if you'd like to try again."
    else
	  if test -f ${INSTALL_DIR}/java/classes/old_resource.jar
	     then
		rm -rf ${INSTALL_DIR}/java/classes/resource.jar
		mv ${INSTALL_DIR}/java/classes/old_resource.jar ${INSTALL_DIR}/java/classes/resource.jar
	  fi
          if test -d ${INSTALL_DIR}/old_nethelp
             then
                 rm -rf ${INSTALL_DIR}/nethelp
                 mv ${INSTALL_DIR}/old_nethelp ${INSTALL_DIR}/nethelp
          fi
          if test -f ${INSTALL_DIR}/old_bookmark.htm
             then
                 rm -rf ${INSTALL_DIR}/bookmark.htm
                 mv ${INSTALL_DIR}/old_bookmark.htm ${INSTALL_DIR}/bookmark.htm
          fi
fi
exit 0
