#!/bin/bash
# Copyright (C) 2004 Networks Associates Technology Inc.  All rights reserved.

if [ -f $NETAWSS/.profile.vars ]; then
    . $NETAWSS/.profile.vars
else
    . /var/NAIENV/.profile.vars
fi

shopt -s extglob
shopt -s nullglob
umask 022

rephead=( \
    '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' \
    '<ReplaceXml>' \
    '<Children xpath="/AboutBox/HotFixes">' \
)
reptail=( \
    '</Children>' \
    '</ReplaceXml>' \
)

repfile=/tmp/rep.xml.$$

printf '%s\n' "${rephead[@]}" >$repfile
for f in $NETAWSS/hotfixes/about/*; do
    echo "<HotFix name=\"${f##*/}\" isodate=\"$(date -ur $f +%Y%m%dT%H%M%S)\"/>"
done >>$repfile
printf '%s\n' "${reptail[@]}" >>$repfile

for f in $NETAWSS/ui/aboutbox/*/aboutbox.xml; do
    [[ -e $f.orig ]] || cp -p "$f" "$f.orig"
    $WSMGMT/xml-replace $repfile "$f" "$f"
done
rm -f $repfile

exit 0
