Blame Inventory

Packit 6f02de
#!/bin/sh
Packit 6f02de
#
Packit 6f02de
# Inventory -- take an inventory of the lsof distribution's 00MANIFEST
Packit 6f02de
Packit 6f02de
# Establish trap and stty handling.
Packit 6f02de
Packit 6f02de
ISIG=":"
Packit 6f02de
trap '$ISIG; exit 1'  1 2 3 15
Packit 6f02de
stty -a 2>&1 | grep isig > /dev/null
Packit 6f02de
if test $? -eq 0
Packit 6f02de
then
Packit 6f02de
  stty -a 2>&1 | egrep -e -isig > /dev/null
Packit 6f02de
  if test $? -eq 0
Packit 6f02de
  then
Packit 6f02de
    ISIG="stty -isig"
Packit 6f02de
    stty isig
Packit 6f02de
  fi
Packit 6f02de
fi
Packit 6f02de
Packit 6f02de
# Establish echo type -- Berkeley or SYSV.
Packit 6f02de
Packit 6f02de
j=`echo -n ""`
Packit 6f02de
if test "X$j" = "X-n "
Packit 6f02de
then
Packit 6f02de
  EC="\c"
Packit 6f02de
  EO=""
Packit 6f02de
else
Packit 6f02de
  EC=""
Packit 6f02de
  EO="-n"
Packit 6f02de
fi
Packit 6f02de
Packit 6f02de
# Display the introduction and basic explanation.
Packit 6f02de
Packit 6f02de
cat << .CAT_MARK
Packit 6f02de
Packit 6f02de
This configuration step (the Inventory script) takes inventory of
Packit 6f02de
the lsof distribution.  The script runs for a minute or two while
Packit 6f02de
it checks that all the subdirectories, information files, scripts,
Packit 6f02de
header files and source files that should be present really are.
Packit 6f02de
Packit 6f02de
It's not absolutely necessary that you take inventory, but it's a
Packit 6f02de
good idea to do it right after the lsof distribution has been
Packit 6f02de
unpacked.  Once the inventory has been taken, this script creates
Packit 6f02de
the file ./.ck00MAN as a signal that the inventory step has been
Packit 6f02de
done.
Packit 6f02de
Packit 6f02de
You can call the Inventory script directly at any time to take
Packit 6f02de
inventory.  You can inhibit the inventory step permanently by
Packit 6f02de
creating the file ./.neverInv, and you can tell the Configure script
Packit 6f02de
to skip the inventory and customization steps with the -n option.
Packit 6f02de
.CAT_MARK
Packit 6f02de
Packit 6f02de
END=0
Packit 6f02de
while test $END = 0
Packit 6f02de
do
Packit 6f02de
  echo ""
Packit 6f02de
  echo $EO "Do you want to take inventory (y|n) [y]? $EC"
Packit 6f02de
  read ANS EXCESS
Packit 6f02de
  if test "X$ANS" = "Xn" -o "X$ANS" = "XN"
Packit 6f02de
  then
Packit 6f02de
    exit 0
Packit 6f02de
  fi
Packit 6f02de
  if test "X$ANS" = "Xy" -o "X$ANS" = "XY" -o "X$ANS" = "X"
Packit 6f02de
  then
Packit 6f02de
    END=1
Packit 6f02de
  else
Packit 6f02de
    echo ""
Packit 6f02de
    echo "Please answer y or n."
Packit 6f02de
  fi
Packit 6f02de
done
Packit 6f02de
Packit 6f02de
# The current directory is assumed to be the lsof distribution home.
Packit 6f02de
Packit 6f02de
D=`pwd`
Packit 6f02de
Packit 6f02de
# If .ck00MAN exists, the manifest has already been checked.
Packit 6f02de
# See if the caller wants to check it again.
Packit 6f02de
Packit 6f02de
CK=$D/.ck00MAN
Packit 6f02de
if test -r $CK
Packit 6f02de
then
Packit 6f02de
  cat << .CAT_MARK
Packit 6f02de
Packit 6f02de
======================================================================
Packit 6f02de
Packit 6f02de
The lsof distribution inventory in 00MANIFEST has already been checked.
Packit 6f02de
.CAT_MARK
Packit 6f02de
Packit 6f02de
  END=0
Packit 6f02de
  while test $END = 0
Packit 6f02de
  do
Packit 6f02de
    echo ""
Packit 6f02de
    echo $EO "Do you want to check the inventory again (y|n) [n]? $EC"
Packit 6f02de
    read ANS EXCESS
Packit 6f02de
    if test "X$ANS" = "Xn" -o "X$ANS" = "XN" -o "X$ANS" = "X"
Packit 6f02de
    then
Packit 6f02de
      exit 0
Packit 6f02de
    else
Packit 6f02de
      if test "X$ANS" = "Xy" -o "X$ANS" = "XY"
Packit 6f02de
      then
Packit 6f02de
	END=1
Packit 6f02de
      else
Packit 6f02de
	echo ""
Packit 6f02de
	echo "Please answer y or n."
Packit 6f02de
      fi
Packit 6f02de
    fi
Packit 6f02de
  done
Packit 6f02de
fi
Packit 6f02de
echo ""
Packit 6f02de
Packit 6f02de
# See if manifest exists.  Exit if it does not.
Packit 6f02de
Packit 6f02de
if test ! -r 00MANIFEST
Packit 6f02de
then
Packit 6f02de
  echo "FATAL: 00MANIFEST file not found or not readable; Inventory exits."
Packit 6f02de
  echo ""
Packit 6f02de
  exit 1
Packit 6f02de
fi
Packit 6f02de
Packit 6f02de
# Start the inventory.
Packit 6f02de
Packit 6f02de
S=""
Packit 6f02de
echo "Conducting an inventory of the lsof distribution; this will take a while."
Packit 6f02de
echo ""
Packit 6f02de
echo $EO "Examining ${D}:$EC"
Packit 6f02de
ERR=0
Packit 6f02de
OK=1
Packit 6f02de
for i in `cat 00MANIFEST | sed 's/\*$//'`
Packit 6f02de
do
Packit 6f02de
  if test "X$i" != "X"
Packit 6f02de
  then
Packit 6f02de
    j=`expr $i : '\(.*\)/$'`
Packit 6f02de
    if test "X$j" != "X" -a "X$j" != "X0"
Packit 6f02de
    then
Packit 6f02de
Packit 6f02de
    # Check a subdirectory reference.
Packit 6f02de
Packit 6f02de
      if test ! -d ${D}/${S}/$j
Packit 6f02de
      then
Packit 6f02de
	if test $OK = 1
Packit 6f02de
	then
Packit 6f02de
	  echo ""
Packit 6f02de
	fi
Packit 6f02de
	echo "    Subdirectory ${S}/$j is missing. ++++"
Packit 6f02de
	ERR=1
Packit 6f02de
	OK=0
Packit 6f02de
      fi
Packit 6f02de
    else
Packit 6f02de
      s=`expr $i : '\(.*\):$'`
Packit 6f02de
      if test "X$s" != "X" -a "X$s" != "X0"
Packit 6f02de
      then
Packit 6f02de
Packit 6f02de
      # Process a subdirectory change.
Packit 6f02de
Packit 6f02de
	if test $OK -eq 1
Packit 6f02de
	then
Packit 6f02de
	  echo " OK"
Packit 6f02de
	fi
Packit 6f02de
	OK=1
Packit 6f02de
	S=$s
Packit 6f02de
	echo $EO "Examining $S:$EC"
Packit 6f02de
	if test ! -d ${D}/$S
Packit 6f02de
	then
Packit 6f02de
	  echo " ERROR"
Packit 6f02de
	  echo "    Subdirectory $S is missing. ++++"
Packit 6f02de
	  ERR=1
Packit 6f02de
	  OK=0
Packit 6f02de
	fi
Packit 6f02de
      else
Packit 6f02de
Packit 6f02de
	# Process a file reference.
Packit 6f02de
Packit 6f02de
	if test ! -r ${D}/${S}/$i
Packit 6f02de
	then
Packit 6f02de
	  if test $OK -eq 1
Packit 6f02de
	  then
Packit 6f02de
	    echo " ERROR"
Packit 6f02de
	  fi
Packit 6f02de
	  echo "    File ${S}/$i is missing. ++++"
Packit 6f02de
	  ERR=1
Packit 6f02de
	  OK=0
Packit 6f02de
	fi
Packit 6f02de
      fi
Packit 6f02de
    fi
Packit 6f02de
  fi
Packit 6f02de
done
Packit 6f02de
if test $OK -eq 1
Packit 6f02de
then
Packit 6f02de
  echo " OK"
Packit 6f02de
fi
Packit 6f02de
echo ""
Packit 6f02de
if test $ERR -ne 0
Packit 6f02de
then
Packit 6f02de
  echo "+++++++++++++++++++++++++++++++++++++++++++++++"
Packit 6f02de
  echo "+                                             +"
Packit 6f02de
  echo "+  SOME FILES OR DIRECTORIES MAY BE MISSING!  +"
Packit 6f02de
  echo "+                                             +"
Packit 6f02de
  echo "+++++++++++++++++++++++++++++++++++++++++++++++"
Packit 6f02de
else
Packit 6f02de
  echo "This lsof distribution seems to be complete."
Packit 6f02de
fi
Packit 6f02de
echo ""
Packit 6f02de
echo "" >> $CK
Packit 6f02de
exit $ERR