PerforceBackupProcedureRSS #1

  • //
  • guest/
  • philip_kania/
  • AdminScripts/
  • PerforceBackupProcedureRSS
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#!/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

# <Functions>

function RssStart()
{
    local rssGenerator=$(basename ${0})
    cat <<EOF
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>$rssTitle</title>
<link>$rssLink</link>
<description>$rssDescription</description>
<language>en-us</language>
<pubDate>$(date)</pubDate>
<lastBuildDate>$(date)</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>$rssGenerator</generator>
<managingEditor>$rssManagingEditor</managingEditor>
<webMaster>$rssWebMaster</webMaster>
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
</channel>
</rss>
EOF
}

# </Functions>

# <Initialize>

rssTitle="Perforce Backup Procedure Results"
rssDescription="Summary of Perforce server backup procedure results with links to full results."

xslFile="PerforceBackupProcedureRSS.xsl"

# </Initialize>

# <Main>

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

# </Main>

# Change User Description Committed
#1 7202 Philip Kania Added scripts to generate RSS feeds.
Updated template configuration scripts to run RSS scripts.