#!/bin/sh

# bbclient
# SCRIPT TO CREATE BIG BROTHER CLIENT TARBALLS
# Sean MacGuire - The MacLawran Group Inc.
# Version 1.3
# November 7, 1999

#
# This program is Copyright (c) 1997-1999
# The MacLawran Group Inc.
# All Rights Reserved
#
# THIS SCRIPT MUST BE RUN FROM HERE!
# USE ONLY IF THE CLIENTS ARE RUNNING THE SAME OS!!!
#
# Format: bbclient <CLIENT-MACHINE-NAME>
#

if test "$#" != "1"
then
	echo "bbclient: Wrong number of arguments!
	Format: ./bbclient [client-machine-name]"
	exit 1
else
	CLIENT=$1
fi

#
# FIRST, SEE IF THIS MACHINE IS EITHER THE DISPLAY SERVER
# THE PAGER SERVER, OR BOTH...
#
grep "$CLIENT" ../etc/bb-hosts > /tmp/BB.$$
if test "$?" != "0"
then
	echo "bbclient: $CLIENT not defined in ../etc/bb-hosts!"
	exit 2
fi

# START MAKING THE CLIENT LIST...
# EVERY ONE GETS THESE...

echo "*** Adding standard things..."
echo "bb/README
	bb/README.INSTALL
	bb/LICENSE
	bb/runbb.sh
	bb/tmp/.helloworld
	bb/etc
	bb/bin
	bb/ext
	bb/bin/bb-local.sh
	bb/bin/bb
	bb/bin/bbrun" > /tmp/BBLIST


grep BBDISPLAY /tmp/BB.$$ > /dev/null 2>&1
if test "$?" = "0"		# WE'RE A DISPLAY SERVER
then
	echo "*** Adding Big Brother Display things..."
	BBSERVER="TRUE"
	echo "	bb/www/
		bb/web/" >> /tmp/BBLIST
fi

grep BBPAGER /tmp/BB.$$ > /dev/null 2>&1
if test "$?" = "0"
then
	echo "*** Adding Big Brother Pager Server things..."
	# Add only if host is not BBDISPLAY also
	if test "$BBSERVER" != "TRUE"
	then
		echo "	bb/www/
			bb/web/" >> /tmp/BBLIST
		BBSERVER="TRUE"
	fi
fi

grep BBNET /tmp/BB.$$ > /dev/null 2>&1
if test "$?" = "0"
then
	echo "*** Adding Big Brother Network Monitor things..."
	# Nothing to add for now
fi

#
# IF WE NEED THE BIG BROTHER DAEMON ON THIS MACHINE THEN ADD IT
#
if test "$BBSERVER" = "TRUE"
then
	echo "*** Adding Big Brother Daemon..."
	# Nothing to add for now
fi
rm -f /tmp/BB.$$		# DON'T NEED THIS ANY MORE...

cd ../..
echo "*** Creating tar file for Big Brother on $CLIENT"
tar cvf bb-${CLIENT}.tar `cat /tmp/BBLIST`
rm -f /tmp/BBLIST

echo "*** Done.

The Big Brother Client archive has been created.  It's called:
	bb-${CLIENT}.tar
and lives in the directory above the bb directory.

You can now install Big Brother on ${CLIENT}

Do not forget to edit PROCS/PAGEPROC in bbdef.sh on ${CLIENT}
Also modify BBHOME and BBEXT in runbb.sh if required"
