#!/bin/sh
#
# Post install script for IMNSearch cgi
#       1) Copy files from /usr/docsearch/cgi-bin
#       2) change ownership and permissions to imnadm:imnadm
#
# script debug flag
#set -x
# Put in names of CGI to be installed
cgi_name_1="db2srsen.exe"
cgi_name_2="db2srsbcs"
dummy()
{
return
}
system=`uname`
case "$system" in
        "AIX")  ECHO=echo
                ;;
        "HP-UX")ECHO=dummy
                ;;
        "SunOS")ECHO=dummy
                ;;
        *)      echo "Operating system not supported."
                exit 1
                ;;
esac
umask 022

# system commands with full path
sys_cp="/usr/bin/cp"
sys_chmod="/usr/bin/chmod"
sys_chown="/usr/bin/chown"

# CGI source directory
src_cgi_dir="/usr/docsearch/cgi-bin"
# CGI directory specified in the httpd.conf file
trg_cgi_dir="/var/docsearch/cgi-bin"

count=1
while [ ! -z "`eval echo \\$cgi_name_$count`" ]
do
  cgi_name="`eval echo \\$cgi_name_$count`"

  if [ -x /usr/bin/imnss ]
  then
        # copy cgi and change permission and ownwership
        $sys_cp $src_cgi_dir/$cgi_name $trg_cgi_dir
        if [ $? -ne 0 ]
        then
          $ECHO "Error copying index files to directory !"
          $ECHO "Exiting ..."
          exit 1
        fi

        $sys_chown -R imnadm:imnadm $trg_cgi_dir/$cgi_name
        if [ $? -ne 0 ]
        then
          $ECHO "Error changing ownership of file !"
          $ECHO "Exiting ..."
          exit 1
        fi

        $sys_chmod 6555 $trg_cgi_dir/$cgi_name
        if [ $? -ne 0 ]
        then
          $ECHO "Error changing file permissions !"
          $ECHO "Exiting ..."
          exit 1
        fi

  fi
  count=`expr $count + 1`
done
exit 0
