#!/sbin/sh
#########################################################################
# 									
#   File:	 decustomize
#   Description: /etc/update decustomization script for HPXT2-ICA fileset
# 
#########################################################################
#

set -a

PATH="/bin:/usr/bin:/etc:/usr/sbin:/sbin:/usr/ucb:/usr/ccs/bin:."
FILESET=HPXT2-ICA


STUB=/etc/dt/appconfig/appmanager/C/Netstations
if [ -d $STUB ]
then
  rm -f $STUB/HpnsICA
  rm -f $STUB/HpnsICA
fi

STUB=/opt/hpxt/enware2/usr/vue/config/types/tools/Netstations
if [ -d $STUB ]
then
  rm -f $STUB/HpnsICA
  rm -f $STUB/HpnsICA
fi


#-------------------------------------------------------------------#
# remove ICA lines from directives file
#-------------------------------------------------------------------#
#
DIRECTIVES=/opt/hpxt/enware2/xthome/bin/directives

if [ -f $DIRECTIVES ]
then
  sed '/BEGIN ICA/,/END ICA/d' $DIRECTIVES > $DIRECTIVES.new.$$
  if [ -s $DIRECTIVES.new.$$ ]
  then
    cmp -s $DIRECTIVES $DIRECTIVES.new.$$
    if [ $? -ne 0 ]
    then
      cp $DIRECTIVES $DIRECTIVES.orig.$$
      cp $DIRECTIVES.new.$$ $DIRECTIVES
    fi
  fi
fi

rm -f $DIRECTIVES.new.$$


#-------------------------------------------------------------------#
# remove ICA lines from config files
#-------------------------------------------------------------------#
#
CFGS="/opt/hpxt/enware2/config/sample.cfg /opt/hpxt/enware2/config/default.cfg"

for CONFIG in $CFGS
do
  if [ ! -f "$CONFIG" ]
  then
    continue
  fi

  sed '/BEGIN ICA/,/END ICA/d' $CONFIG > $CONFIG.new.$$
  if [ -s $CONFIG.new.$$ ]
  then
    cmp -s $CONFIG $CONFIG.new.$$
    if [ $? -ne 0 ]
    then
      cp $CONFIG $CONFIG.orig.$$
      cp $CONFIG.new.$$ $CONFIG
    fi
  fi
  rm -f $CONFIG.new.$$
done


exit 0
