Blame Inventory

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