#!/bin/bash
# Copyright (c) 2009 Exemplics LLC
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Version 2009.3
#
function RssStart()
{
local rssGenerator=$(basename ${0})
cat <$rssTitle
$rssLink
$rssDescriptionen-us$(date)$(date)http://blogs.law.harvard.edu/tech/rss$rssGenerator$rssManagingEditor$rssWebMaster
EOF
}
function CreateRssItem()
{
local logFile=${1}
local rssItem=$(echo ${logFile} | sed -n 's/\.xml/.rssitem.xml/p')
# Generate new rssItem if logFile is newer than rssItem or rssItem
# does not exist.
if [[ "${logFile}" -nt "${rssItem}" ]]; then
xsltproc --output ${rssItem} --stringparam uri "${rssLink}/${logFile}" ${xslFile} ${logFile}
fi
}
function RssEnd()
{
cat <
EOF
}
#
#
rssTitle="Perforce Backup Procedure Results"
rssDescription="Summary of Perforce server backup procedure results with links to full results."
xslFile="PerforceBackupProcedureRSS.xsl"
#
#
pushd "${logDirectory}" > /dev/null
# Try tac or gtac to reverse the order
# if your system does not support tail -r.
# Create RSS fragments in the order the log files were created.
ls -t *.BackupProcedure.xml | tail -r | while read line
do
CreateRssItem ${line}
done
RssStart > "${rssFeedFile}"
# Concatenate the RSS fragments newest to oldest.
ls -t *.rssitem.xml | xargs -n1 cat >> "${rssFeedFile}"
RssEnd >> "${rssFeedFile}"
popd > /dev/null
#