#!/bin/sh
################################################################################
# Name: /IBM/bin/cfInfo
# Purpose:
#   Retrieve information about the flash card and put into files for SNMP to use
################################################################################

# does flash card exist
/bin/dd if=/dev/hda of=/tmp/.flash-check bs=1 count=1 > /dev/null 2>&1

if [ $? = "0" ]; then

   rm -f /tmp/.flash-check
   # Get the total size in bytes
   TOTAL_SIZE=`expr \`/sbin/sfdisk -s /dev/hda\` \* 1024`
   echo $TOTAL_SIZE > /tmp/snmp/44

   # Get the available size of the flash card in 512 byte blocks
   INFO=`/IBM/bin/IBMdf --block-size=512 /dev/hda | grep -E "/dev/hda" | grep -v "No such" | tr -s " "`

   AVAIL_SIZE=`echo $INFO | cut -f4 -d" "`
   echo $AVAIL_SIZE > /tmp/snmp/45

   # Get the formatted size of the flash card
   FORMAT_SIZE=`echo $INFO | cut -f2 -d" "`
   echo $FORMAT_SIZE > /tmp/snmp/46
else 

   echo 0 > /tmp/snmp/44
   echo 0 > /tmp/snmp/45
   echo 0 > /tmp/snmp/46
fi
   
