#!/bin/sh

#  Licensed Materials - Property of IBM
#
#  5765-F32
#  5765-F36
#  (C) Copyright IBM Corporation 2002-2004
#
#  ALL rights reserved.
#  US Government Users Restricted Rights -
#  Use, duplication or disclosure restricted by GSA ADP
#  Schedule Contract with IBM Corporation.
#


baseDir=/opt/IMinerX/V8.2

if [ ! -x $baseDir/bin/idmuscan ]
then
  echo "ERROR: idmuscan is not accessible or missing from the installation!"
  echo "Please make sure that no files were deleted from your installation,"
  echo "especially idmuscan."
  exit 1
fi


# Get the logfile
if [ "$1" != "" ]
then
  LOGFILE=$1
  # Now clear the logfile
  if [ -r $LOGFILE ]
  then
    rm -f $LOGFILE
  fi
  touch $LOGFILE
  if [ "$?" != "0" ]
  then
    echo "Error: cannot create specified logfile $LOGFILE. Insufficient privileges?"
    exit 1
  fi
  # Display system info
  $baseDir/bin/idmuscan - $LOGFILE
  # Search for all Files in the directory to scan
  find $baseDir/bin -type f -exec $baseDir/bin/idmuscan {} $LOGFILE \;
  if [ -d $baseDir/lib ]
  then
    find $baseDir/lib -type f -exec $baseDir/bin/idmuscan {} $LOGFILE \;
  fi
  if [ -d $baseDir/lib64 ]
  then
    find $baseDir/lib64 -type f -exec $baseDir/bin/idmuscan {} $LOGFILE \;
  fi
else
  # Display system info
  $baseDir/bin/idmuscan -
  # Search for all Files in the directory to scan
  find $baseDir/bin -type f -exec $baseDir/bin/idmuscan {} \;
  if [ -d $baseDir/lib ]
  then
    find $baseDir/lib -type f -exec $baseDir/bin/idmuscan {} \;
  fi
  if [ -d $baseDir/lib64 ]
  then
    find $baseDir/lib64 -type f -exec $baseDir/bin/idmuscan {} \;
  fi
fi
