#!/bin/sh

# mkbb.comp
# SCRIPT TO DETERMINE COLUMNS TO DISPLAY IN COMPRESSED FORMAT
# Sean MacGuire - The MacLawran Group Inc.
# Version 14
# Mar 05th, 2000
#
# This program is Copyright (c) 1997-2000
# The MacLawran Group Inc.
# All Rights Reserved

#
# WE NEED AT LEAST ON ARGUMENT....
#
if test "$#" = 1
then
	BBHOSTLINE="$1"
else
	exit
fi

if test ! "$BBTMP"                      # GET DEFINITIONS IF NEEDED
then
        . $BBHOME/etc/bbdef.sh          # INCLUDE STANDARD DEFINITIONS
fi

if test "$SUBPAGE" = "TRUE"
then
	BBHOSTS="$BBTMP/bb-hosts"
fi

BBHOSTEND=`$CAT $BBHOSTS | $WC`
BBHOSTEND=`expr $BBHOSTEND + 0`

cat $BBHOSTS | $SED 1,${BBHOSTLINE}d |
while read line
do
	BBHOSTLINE=`expr $BBHOSTLINE + 1`

	echo $line | $GREP "^group" > /dev/null
	if test "$?" = 0
	then
		if test "$BBARGS"
		then
			echo $BBARGS
		fi
		exit
	fi

	# SMM SANITY CHECK
	echo $line | $GREP "^[0-9]" > /dev/null
	if test "$?" = "0"
	then
		set $line > /dev/null

		if test "$FQDN" = "TRUE"
       		then
               		MACHINE=`echo $2 | $SED "s/\./,/g"`
       		else
               		set `echo $2 | $SED "s/\./ /"`
               		MACHINE=$1
		fi
		BBARGS="$BBARGS ${MACHINE}.*"	# ADD A LINE
	fi
	#
	# MAKE SURE THE LAST GROUP GETS HANDLED OK...
	#
	if test "$BBHOSTLINE" = "$BBHOSTEND"	# LAST LINE
	then
		if test "$BBARGS"
		then
			echo $BBARGS
		fi
		exit			# LEAVE, NOW!
	fi
done
