#!/bin/sh

BCNUNOLOG="yes"

#. /usr/local/bcnu/etc/bcnuenv
. $BCNUHOME/agent/agent_head

#set -x
# create new directory etc
BCNUCONFIG=/tmp/bcnuconfig
MYHOST=`uname -n`
# clean up
rm -r $BCNUCONFIG 2>/dev/null
rm $BCNUCONFIG.tar.Z 2>/dev/null
mkdir $BCNUCONFIG 2>/dev/null
# start getting data
	case "$BCNUSERVER" in
	HPUX10)
		bdf >$BCNUCONFIG/disk_space
		/etc/ifconfig lan0 >$BCNUCONFIG/ifconfig_lan0
		/etc/swapinfo -a >$BCNUCONFIG/swapinfo_-a
		/etc/sysdef >$BCNUCONFIG/sysdef
		/etc/dmesg >$BCNUCONFIG/dmesg
		/usr/sbin/swlist -l product >$BCNUCONFIG/installed_software
		/etc/ioscan >$BCNUCONFIG/ioscan
		cp /etc/fstab $BCNUCONFIG/fstab
		{
		/etc/vgdisplay -v

		for disk in `ls /dev/vg??/lvol*`
		do 
			/etc/lvdisplay $disk 
		done

		for disk in `ls /dev/dsk/*`
		do 
			/etc/pvdisplay $disk 
		done
		} > $BCNUCONFIG/disks
		{
		for disk in `grep hfs /etc/fstab | cut -f1 -d" "`
		do
			/etc/mkfs -m $disk
		done
		} >$BCNUCONFIG/mkfs
		ls /system >$BCNUCONFIG/ls_system
		cp /etc/checklist $BCNUCONFIG/checklist
		;;
	AIX)
		df -k >$SYSTEMS/$hostname/disk_space
		ifconfig en0 >$BCNUCONFIG/ifconfig_en0
		lslpp -L all >$BCNUCONFIG/lslpp_-L_all
		lsps -a >$BCNUCONFIG/lsps_-a
		lsfs >$BCNUCONFIG/lsfs
#		rcp $SCRIPTS/lvm.AIX $hostname:/tmp/lvm
#		rsh $hostname "ksh /tmp/lvm" >$SYSTEMS/$hostname/lvminfo
		lscfg -v >$BCNUCONFIG/lscfg_-v
		;;
	solaris)
		df -k >$BCNUCONFIG/disk_space
		/usr/sbin/ifconfig -a >$BCNUCONFIG/ifconfig_-a
		pkginfo >$BCNUCONFIG/pkginfo
		showrev -p >$BCNUCONFIG/showrev_-p
		showrev >$BCNUCONFIG/showrev
		/etc/swap -l >$BCNUCONFIG/swap_-l
		/etc/sysdef >$BCNUCONFIG/sysdef
		/etc/prtconf >$BCNUCONFIG/prtconf
		dmesg >$BCNUCONFIG/dmesg
		cp /etc/system $BCNUCONFIG/system
		cp /etc/vfstab $BCNUCONFIG/vfstab
		cp /etc/opt/SUNWmd/md.tab $BCNUCONFIG/md.tab
		/usr/opt/SUNWmd/sbin/metastat >$BCNUCONFIG/metastat
		/usr/opt/SUNWmd/sbin/metastat -p >$BCNUCONFIG/metastat_-p
		/usr/opt/SUNWmd/sbin/metadb -i >$BCNUCONFIG/metadb_-i
		ps -ef >$BCNUCONFIG/ps_-ef
		{
		for disk in /dev/rdsk/*s2 
		do 
			echo $disk
			/etc/prtvtoc $disk 
		done
		} >$BCNUCONFIG/disks
		{
		for disk in `grep rdsk /etc/vfstab | cut -f2`
		do
			echo $disk
			/etc/mkfs -m $disk
		done
		} >$BCNUCONFIG/mkfs

		;;
	esac
# common routines for all platforms
	ls -l / >$BCNUCONFIG/ls_-l_root
	lpstat -s >$BCNUCONFIG/lpstat_-s
	ipcs -a >$BCNUCONFIG/ipcs_-a
	pr -f /var/spool/cron/crontabs/* >$BCNUCONFIG/crontabs
	uname -a  >$BCNUCONFIG/uname_-a

# Create tar file for transferring
cd $BCNUCONFIG
tar cf $BCNUCONFIG.tar *
cd
compress $BCNUCONFIG.tar
BCNUMSG="$BCNU -m 'ok - Configs updated' -f $BCNUCONFIG.tar.Z -n /data/configs/$MYHOST.tar.Z -e '-1' $BCNUHOST"
bcnu_send

