#!/bin/bash
# $Header: /cvs/WebShield/wsrc/files/mgmt/replace_extra_rules,v 1.2 2004/02/02 14:19:15 bwhittak Exp $
#
# (C) Copyright Networks Associates Techonolgy Inc. 2003
#
# Called by the UI to add an extra.rule file obtained from user.
#
if [ -f $NETAWSS/.profile.vars ]; then
    . $NETAWSS/.profile.vars
else
    . /var/NAIENV/.profile.vars
fi
[[ "$PATH" == "$wsPATH":* || -z "$wsPATH" ]] || PATH=$wsPATH:$PATH

shopt -s extglob
shopt -s nullglob
. spam-functions

[[ $# -gt 0 ]] || exit 1
newdir=$1	# directory we're getting the new RPMs from
shift
rpms=( "$newdir"/*.rpm )
[[ ${#rpms[@]} -gt 0 ]] || exit 0	# nothing to do

rm -rf $SPAMRPMEXTRA/*.rpm	# remove the old ones

for f in "${rpms[@]}"; do
    add_extra_rule "$f"		# should work, nothing we can do if not
done

exit 0
