#!/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

#need to set the lang so that the string compares work for /IBM/bin/IBMdf
LANG=en_US

if [ -d /boot/grub -a \( "$MODEL_TYPE" = "N70" -o "$MODEL_TYPE" = "BIOS" \) ]; then
   echo 120000 > /tmp/snmp/44
   echo 90000 > /tmp/snmp/45
   echo 120000 > /tmp/snmp/46
   exit
fi

if [ "$MODEL_TYPE" = 2200 -o "$MODEL_TYPE" = 2800 ]; then
        FLASHDEV=/dev/hda
else
        FLASHDEV=/dev/hdd
fi

/bin/dd if=$FLASHDEV 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 $FLASHDEV\` \* 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 $FLASHDEV | grep -E "$FLASHDEV" | 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
   
