#! /bin/sh

function install() {
 if alert "This will install antiword in /boot/home/config/bin and its files in /boot/home/config/apps/antiword -- Proceed?" NO OK ; then
  alert "antiword will not be installed"
  exit ; fi
 if [ -e $BASEDIR/bin/antiword ] ; then
  if alert --warn "'antiword' is already installed -- Do you really want to replace it?" "NO!" "Yes, please" ; then
  alert "antiword will not be installed"
  exit ; fi
 fi
  mkdir -p $BASEDIR/bin 2>/dev/null
  mv -f antiword $BASEDIR/bin
  mkdir -p $BASEDIR/apps/antiword 2>/dev/null
  mv -f Resources_BEOS/* $BASEDIR/apps/antiword
  rmdir Resources_BEOS
 mv Install Uninstall
 alert "OK... antiword has been installed"
}

function remove() {
 if alert "Really uninstall antiword?" NO "Yes, please" ; then
	alert "antiword will not be removed from $BASEDIR"
  exit ; fi
  if [ -e antiword ] ; then rm -f $BASEDIR/bin/antiword
 	else mv $BASEDIR/bin/antiword .
  fi
  if [ -e Resources_BEOS ] ; then rm -r $BASEDIR/apps/antiword
  else
   mkdir Resources_BEOS
   mv $BASEDIR/apps/antiword/* Resources_BEOS
   rmdir $BASEDIR/apps/antiword
  fi
 mv Uninstall Install
 alert "antiword has been uninstalled back into this folder; For complete removal delete this folder as well."
}

wdir=$(dirname "$0")
cd "$wdir"
BASEDIR="/boot/home/config"
if [ $(basename "$0") = "Uninstall" ] ; then remove;
else install; fi

