#!/bin/sh
#
# CCFW VPD initialization script for the Hardware Management Console
#
# Description: Setup VPD stuff.
#
# Change Activity:
#   03/05/2004 K. Schroeder -01 Initial creation
#   03/18/2004 B. Dovin     -02 added syslog.conf settings
#   07/21/2004 B. Dovin     -03 added ln to chled
#   06/15/2005 P. Callaghan -04 do not use /mnt/dos for VPD info
#   09/13/2006 K. Schroeder -05 Add creating link for R&V graphics
#   10/17/2006 K. Schroeder -06 Fix directory name for R&V graphics

# define a function to do all of our work so that we can scope the
# variables to only our script and not the caller.
doInit() {
   local user="$2"

   mkdir -p $1/data/pciinfo
   chown :$2 $1/data/pciinfo
   chmod 775 $1/data/pciinfo

   # Process /proc directory information
   #   to create $1/data/pciinfo/sys_info.out
   java com.ibm.hwmca.fw.util.GetInfo $1/data/pciinfo/sys_info.out $1/data/pciinfo/sys_info.log $1/data/DiskModelIgnoreLeading > $1/getinfo.out 2>&1 #-04
   su -m $user --command="iqyp33pn" > $1/iqyp33pn.out 2>&1
   if !(ls '/opt/ccfw/native/runAsRoot/chled')
    then
      echo making symbolic link to chled
      ln -s  /opt/hsc/bin/command/chled /opt/ccfw/native/runAsRoot/
   fi   
   
   local syslogConf="*.*                            |/var/log/sysloghmcpipe"

   if !(ls '/var/log/sysloghmcpipe')
    then
      echo making sysloghmcpipe
      mkfifo /var/log/sysloghmcpipe
   fi
   grep "/var/log/sysloghmcpipe" /etc/syslog.conf
   syslogPipeRc=$?
   if [ $syslogPipeRc -eq 0 ]; then
      echo sysloghmcpipe was there assume that all is set
   else
        echo updating sylog.conf
        echo "#syslogmonitor settings for now" >> /etc/syslog.conf
        echo "$syslogConf" >> /etc/syslog.conf
   
        echo reload of syslog
       /etc/init.d/syslog reload
   fi
 
   #-05 start
   echo "Creating link for p/service images..."
   mkdir -vp /opt/ccfw/www/res/com/ibm/hwmca/p/service
   chown -v root:ccfw /opt/ccfw/www/res/com/ibm/hwmca/p/
   chown -v root:ccfw /opt/ccfw/www/res/com/ibm/hwmca/p/service/
   chmod -v 775 /opt/ccfw/www/res/com/ibm/hwmca/p/
   chmod -v 775 /opt/ccfw/www/res/com/ibm/hwmca/p/service/
   ln -s /opt/ccfw/com/ibm/hwmca/p/service/images/ /opt/ccfw/www/res/com/ibm/hwmca/p/service/images 
   #-05 end
     
}

# Include the common hmc functions
. $1/hmcfunctions

# do the init processing
doInit $1 $2
