swx_sitemap 835 Bytes
Newer Older
prx's avatar
initial  
prx committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/bin/sh
# création d'un sitemap xml.
# usage : swx_sitemap /dossier/contenant/le/site > sitemap.xml

DIR="$1"
LASTMOD=$(date +%Y-%m-%d)

# Load config file
if [ ! -f $PWD/swx.conf ]; then
	echo "Cannot find swx.conf in current directory"
	exit 1
fi
. $PWD/swx.conf



echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
echo "      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
echo "      xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 "
echo "      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">"
echo "<url>"
echo "<loc>$HOSTNAME</loc>"
echo "<lastmod>$LASTMOD</lastmod>"
echo "</url>"

find "$DIR" -name *.html  | sed -e "s,$DIR,$HOSTNAME/,g" | awk {'print "<url>\n <loc>"$1"</loc>\n</url>"'}

echo "</urlset>"

exit 0