#!/bin/ksh
#
#ident	"@(#)postinstall	1.14	05/05/25 SMI"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#
# Hardware Certification Test Suite installation script
# variables

# variables
#
hname=`hostname`
version=`/usr/bin/uname -r|awk -F. '{print $2}'`
if [  $version -lt 9  ]
then		
	if [  !  -d /var/apache/cgi-bin/SUNWhcts ] 
	then
		ln -s /opt/SUNWhcts /var/apache/cgi-bin/SUNWhcts #modified ".../cgi/bin/hcts" to ".../cgi/bin/SUNWhcts" 
	fi
else
	if [  !  -L /var/apache/cgi-bin/SUNWhcts ] 
        then
                ln -s /opt/SUNWhcts /var/apache/cgi-bin/SUNWhcts #modified for ksh issue on solaris 10
        fi
fi



  if [ ! -f /var/apache/icons/sun_logo_rgb.gif ]
  then
  	cp -p /opt/SUNWhcts/http/sun_logo_rgb.gif /var/apache/icons
  fi


  if [ -f /var/apache/htdocs/index.html ]
  then
	
       mv /var/apache/htdocs/index.html /var/apache/htdocs/index.org.html
  fi
#
	
  cp -p /opt/SUNWhcts/http/index.html /var/apache/htdocs

  rm -f /var/apache/htdocs/common.css
  if [ ! -f /var/apache/htdocs/common.css ]
  then
	cp  /opt/SUNWhcts/http/common.css /var/apache/htdocs
	chmod 644 /var/apache/htdocs/common.css
  fi

  if [ ! -f /var/apache/htdocs/util.js ]
  then
	cp  /opt/SUNWhcts/http/util.js /var/apache/htdocs
	chmod 644 /var/apache/htdocs/util.js
  fi

  rm -rf /var/apache/htdocs/docs
  ln -s /opt/SUNWhcts/docs /var/apache/htdocs/docs

  if [ -z "`/usr/bin/ps -ef|grep httpd|grep -v grep`" ]
  then
	sed  -e "/new.host.name/s/#ServerName new.host.name/ServerName ${hname}/" \
        -e "/Options None/s/Options None/#Options None/" /etc/apache/httpd.conf-example > \
        /etc/apache/httpd.conf
	/usr/apache/bin/apachectl start > /dev/null 2>&1
	#check if httpd is started
	wait
	httpdstatus=`/usr/bin/ps -ef|grep "/usr/apache/bin/httpd"|grep -v "grep"`
	if [ $? -ne 0 ]
	then
		echo "WARNING:"
		echo "httpd could not be started"
	fi
		
  fi
  
# Check for SUNWstaf packages 
/usr/bin/pkginfo | egrep "SUNWstaf" > /dev/null
if [ $? -ne 0 ]
then            # packages are installed

        echo "------------------------------------------------------"
	echo "Package \"SUNWstaf\" is not installed"
	echo "Please use 'pkgadd' to install the package."
	echo "------------------------------------------------------"
	
fi

# Clear previous ssh dir
if [ -d "/.ssh.hcts.bak" ]
then
	rm -r "/.ssh.hcts.bak"
fi

if [ -d "/.ssh" ]
then
        mv /.ssh /.ssh.hcts.bak
fi



