#!/bin/ksh
#######################################################################
#  Find all Palladium servers which have been run on this machine.
#
#  Author:  Alan Hlava
#######################################################################
##########################################################################
# COPYRIGHT:
#    5765-273 (C) COPYRIGHT IBM CORPORATION 1995.
#    All Rights Reserved.
#    Licenced Materials - Property of IBM
#
#    US Government Users Restricted Rights - Use, duplication, or
#    disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
##########################################################################
ME=$(basename $0)

usage()
{
   echo "Syntax:" $ME "(with no flags or paramters)"
   exit 1
}

function errp
{
   if [ $1 -ne 0 ]
   then
      echo $*
   fi
   exit 1
}

function show_objs
{
   A_LIST=`ls $1|grep -v PDB.dir`
   if [ "$A_LIST" != "" ]
   then
      echo "      " $2
      for j in $A_LIST
      do
         echo "         " $j
      done
   fi
}

#----------------------------------------------------------------------
# Parse out the command line options
#----------------------------------------------------------------------
if [ $# != 0 ]
then
   usage
fi

#----------------------------------------------------------------------
# Get the potential server names
#----------------------------------------------------------------------
NAME_LIST=`ls $PDBASE/pdb`
#echo $NAME_LIST

#----------------------------------------------------------------------
# Loop through the names and add them to the spooler or supervisor
# list as appropriate
#----------------------------------------------------------------------
SPLR_LIST=""
SPVR_LIST=""
for i in $NAME_LIST
do
   if test -d $PDBASE/pdb/$i
   then
      if test -f $PDBASE/pdb/$i/spooler/$i
      then
         SPLR_LIST="$SPLR_LIST $i"
      fi

      if test -f $PDBASE/pdb/$i/supervisor/$i
      then
         SPVR_LIST="$SPVR_LIST $i"
      fi
   fi
done

#----------------------------------------------------------------------
# List out the names
#----------------------------------------------------------------------
echo "Spoolers:"
echo "---------"
for i in $SPLR_LIST
do
   echo "   " $i

   show_objs $PDBASE/pdb/$i/log_printer "Logical Printers:"
   show_objs $PDBASE/pdb/$i/queue "Queues:"

done

echo
echo "Supervisors:"
echo "------------"
for i in $SPVR_LIST
do
   echo "   " $i

   show_objs $PDBASE/pdb/$i/suv_phy_printer "Physical Printers:"
done

#----------------------------------------------------------------------
# Finish up and return
#----------------------------------------------------------------------
exit 0

#
#    Version      Date     Time    Owner   Comment
# ------------- -------- -------- -------- ----------------------------
# V             12/05/94 10:56:59 hlava    Original version
