#!/bin/sh
#
#        Copyright(C) 1997 Network Flight Recorder, Inc.
#        All rights reserved.
#
#        Use and distribution of this software and its source code
#        are governed by the terms and conditions of the
#        Network Flight Recorder Software License ("LICENSE.TXT")
#
# File: ls_packages
# Author: Eric Wall (eric@nfr.net)
#

#
# Add /bin to the path to fix some problems people have been
# been having with Linux.
#
PATH=$PATH:/bin

#
# Cgi_GoHome()
#
cd ../../..

#
# go to packages directory
#
cd packages

#
# generate header
#
echo 'content-type: text/plain' ; echo ''

#
# I'm using packagename.cfg to test if a package exists.
#
for pkg_cfg in *.cfg
do
	des=`grep '^title=' $pkg_cfg | sed "s/title=//"`
	pkg=`echo ${pkg_cfg} | sed 's/.cfg$//' `
	echo 'Package:'$pkg';'$des
	#
	# Check that the package's directory exists
	#
	if [ -d $pkg ]
	then
		#
		# Now for each *.cfg in this particular package
		# directory do this stuff
		#
		for bknd_cfg in $pkg/*.cfg
		do
			des=`grep '^title=' $bknd_cfg | sed "s/title=//"`
			gui=`grep '^gui=' $bknd_cfg | sed "s/gui=//"`
			echo $bknd_cfg'='$gui':'$des
		done
	else
		echo '*** Could not find a directory for' $pkg
	fi
done
