#!/bin/sh

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

# Location for the apps-default file
ADLOC="/usr/openwin/lib/locale/ja/app-defaults/";
# Location for the netscape.cfg file
CFGLOC="/usr/openwin/lib/ja/app-defaults/";
# Location for some Misc pieces
MISCLOC="/usr/openwin/lib/locale/ja/netscape/";

#
# 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 -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
