#!/bin/sh

GOOGLESITEMAPFILENAME=sitemap.xml

SITEURLPREFIXFORSEDSTRING="http:\/\/www.pixelmed.com\/"

rm -f ${GOOGLESITEMAPFILENAME}
rm -f ${GOOGLESITEMAPFILENAME}.gz

cat <<EOF >${GOOGLESITEMAPFILENAME}
<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
EOF

ls -1 *.html | sed -e "s/^/<url><loc>${SITEURLPREFIXFORSEDSTRING}/" -e 's/$/<\/loc><\/url>/' >>${GOOGLESITEMAPFILENAME}

echo '</urlset>' >>${GOOGLESITEMAPFILENAME}

gzip <${GOOGLESITEMAPFILENAME} >${GOOGLESITEMAPFILENAME}.gz

exit 0
