#!/bin/sh

SYMLINK=/opt/hpxt/enware2


FILES="SUBNETMASK XSESSIONCHOICE GATEWAY HPXT2VERSION"
for FILE in $FILES 
do
  if [ -f $SYMLINK/lbin/$FILE ]
  then
    rm $SYMLINK/lbin/$FILE > /dev/null
  fi
done


rm -f $SYMLINK/xthome*/bin/directives* > /dev/null 2>&1

rm $SYMLINK > /dev/null 2>&1


#  If bootp seems to be ours remove it from /etc/inetd.conf 
#  and restart inetd	
#
egrep 'enware2.*bootp' /etc/inetd.conf > /dev/null
if [ $? = 0 ]
then
  cp /etc/inetd.conf /etc/inetd.conf.orig.$$
  sed '/[/]enware2[/]bootp[/]bootptab/d' /etc/inetd.conf > /etc/inetd.conf.$$
  if [ -s /etc/inetd.conf.$$ ]
  then
    echo removed bootp entry from /etc/inetd.conf 
    cp /etc/inetd.conf.$$ /etc/inetd.conf
    rm /etc/inetd.conf.$$

    ps -e | awk '$4 == "inetd" {print $4 }' | grep . > /dev/null 2>&1

    if [ $? -eq 0 ]
    then
      PID=`ps -e | awk '$4 == "inetd" {print $1 }' | head -1`
      if [ $PID ]
      then
        kill -1 $PID
        sleep 2
        kill -1 $PID
        echo "Signalled inetd to re-read /etc/inetd.conf"
      else
        echo "WARNING: Couldn't send SIGHUP to inetd."
      fi
    fi
  fi
fi


exit 0
