swx_sitemap 835 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # création d'un sitemap xml.
  3. # usage : swx_sitemap /dossier/contenant/le/site > sitemap.xml
  4. DIR="$1"
  5. LASTMOD=$(date +%Y-%m-%d)
  6. # Load config file
  7. if [ ! -f $PWD/swx.conf ]; then
  8. echo "Cannot find swx.conf in current directory"
  9. exit 1
  10. fi
  11. . $PWD/swx.conf
  12. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  13. echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
  14. echo " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
  15. echo " xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 "
  16. echo " http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">"
  17. echo "<url>"
  18. echo "<loc>$HOSTNAME</loc>"
  19. echo "<lastmod>$LASTMOD</lastmod>"
  20. echo "</url>"
  21. find "$DIR" -name *.html | sed -e "s,$DIR,$HOSTNAME/,g" | awk {'print "<url>\n <loc>"$1"</loc>\n</url>"'}
  22. echo "</urlset>"
  23. exit 0