#!/bin/sh
#
# Postinstallscript written by Ron Record (rr@sco.com)
# Just need to setup the Count configuration
# file with the right hostname and IP. 
# 

scriptname="$0"
step="$1"
keywords="$2"
pkglist="$3"

# Source in the standard functions library, ccsSetup.sh
. ccsSetup.sh

#############################################################################
#
#         fixup the IP, NODE and HOST name in any configuration files
#
#############################################################################
doPostExport()
{
  HOSTPROG=/usr/bin/hostname
  HOST_FILES="/usr/local/etc/Counter/conf/count.cfg"
  if [ -x $HOSTPROG ] 
  then
    HOSTNAME=`$HOSTPROG`
  else
    HOSTNAME=localhost
  fi
  [ "$HOSTNAME" ] || HOSTNAME=localhost
  NODENAME=`uname -n`
  [ "$NODENAME" ] || NODENAME=localhost
  IP=`netstat -i -n | grep net0 | awk ' { print $4 } '`
  [ "$IP" ] || IP=127.0.0.1
  for i in $HOST_FILES
  do
  [ -f $i ] && {
    sed -e "s/132.147.49.40/$IP/g" -e "s/disco.pdev.sco.com/$HOSTNAME/g" < $i > /tmp/_ccs$$
    mv /tmp/_ccs$$ $i
    rm -f /tmp/_ccs$$
  }
  [ -f $i ] && {
    sed -e "s/disco/$NODENAME/g" < $i > /tmp/_ccs$$
    mv /tmp/_ccs$$ $i
    rm -f /tmp/_ccs$$
    chown root:sys $i
  }
  done
}

ccs_return_value=0

case "$step" in
        POST_EXPORT) doPostExport ;;
esac

exit $ccs_return_value

