#!/bin/bash
# $Header: /cvs/WebShield/wsrc/files/mgmt/Attic/add_spam_package,v 1.2 2004/02/02 14:19:13 bwhittak Exp $
#
# (C) Copyright Networks Associates Technology Inc. 2003
#
# Called by the UI to install SpamAssassin RPM zips it's collected 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

# process options
while [[ $# -gt 0 ]]; do
    case $1 in
	(-eng) eng_zip=$2; shift;;
	(-dat) dat_zip=$2; shift;;
	(*) echo "Unrecognised option ignored: $1" >&2;;
    esac
    shift
done

# we'd better have something to do
if [[ -z "$eng_zip" && -z "$dat_zip" ]]; then
    echo "Nothing to do" >&2
    exit
fi

# Do the update
spam-update -local \
    ${eng_zip:+-engzip "$eng_zip"} \
    ${dat_zip:+-datzip "$dat_zip"} \
	</dev/null >/dev/null 2>&1
exit
