#!/bin/sh

# This affects ONLY Unix clients; for Windows clients, get a script
# from somebody with more Windows Clue than I or use the GUI.

#set -- `getopt : $*`
#if [ $? != 0 ]
#then
#echo $USAGE
#exit 2
#fi
#for i in $*
#do
#case $i in
#-a | -b)     FLAG=$i; shift;;
#-o)           OARG=$2; shift 2;;
#--)           shift; break;;
#esac
#done
#
# Eh, screw that; just add to all Unix clients, since that's what I
# need right now.


sudo=''
if [ `id | awk -F\( '{ print $1 }' | awk -F= '{ print $2 }'` -ne 0 ]; then
sudo="sudo "
fi

echo "Warning: this script will create a LOT of temporary files in"
echo `pwd`
echo "Break out now if that's a problem, hit return to confirm."

read spamme

printf "\nAdding servers to:\n"

for client in `sudo bpplclients -allunique -noheader | \
               grep -vi windows | awk '{ print $NF }'`
do

	printf "$client: "

	before=`pwd`/${client}-before-bp.conf
	after=`pwd`/${client}-after-bp.conf

	$sudo bpgp from $client /usr/openv/netbackup/bp.conf $before \
	&& $sudo chmod 644 $before

	cat $before > $after

	for server in $*
	do
		printf "$server "
		echo "SERVER = $server" >> $after
	done

	$sudo bpgp to $client $after /usr/openv/netbackup/bp.conf
#	echo bpgp to $client $after /usr/openv/netbackup/bp.conf
	printf "done.\n"

done

