#!/bin/ksh
#
# jbinv:  ksh script front-end to the jukebox inventory functionality of 
#         arcRead.
#
# Usage:
#
# jbinv [-a acrcFile] -s jbStatFile
#
# -a acrcFile:    specify acrc file.  Optional if ACRC_FILE env. var is set.
# -s jbStatFile:  Name of the output jukebox status file.  Mandatory.
#
# JKH 9/95

#------------------------------------------------------------------------------
# A Usage function
#------------------------------------------------------------------------------

Usage()
{
    echo "Usage:"
    echo ""
    echo "jbinv [-a acrcFile] -s jbStatFile"
    echo ""
    echo "-a acrcFile:    specify acrc file.  Optional if ACRC_FILE environment"
    echo "                variable is set."
    echo "-s jbStatFile:  Name of the output jukebox status file."
    echo ""
}

#------------------------------------------------------------------------------
# main
#------------------------------------------------------------------------------

# Parse command line arguments

if [ $# -lt 2 ]
then
    Usage
    exit 2
fi

set -- `getopt a:s: $*`
if [ $? != 0 ]
then
    Usage
    exit 2
fi

acset=0
statset=0

for i in $*
do
    case $i in
    -a)  ACRCFILE=$2; acset=1; shift 2;;
    -s)  STATFILE=$2; statset=1; shift 2;;
    --)  shift; break;;
    esac
done

if [ $statset -eq 0 ]
then
    Usage
    exit 2
fi

# Now invoke arcRead.

if [ $acset -eq 0 ]
then
    ./arcRead -o $STATFILE
else
    ./arcRead -a $ACRCFILE -o $STATFILE
fi
