sitemap.sh 782 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # url configuration
  3. URL="https://mcmilk.de/"
  4. # values: always hourly daily weekly monthly yearly never
  5. FREQ="weekly"
  6. # begin new sitemap
  7. exec 1> sitemap.xml
  8. # print head
  9. echo '<?xml version="1.0" encoding="UTF-8"?>'
  10. echo '<!-- generator="Milkys Sitemap Generator, https://github.com/mcmilk/sitemap-generator" -->'
  11. echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
  12. # print urls
  13. IFS=$'\r\n' GLOBIGNORE='*' command eval "OPTIONS=($(cat $0.options))"
  14. find . -type f "${OPTIONS[@]}" -printf "%TY-%Tm-%Td%p\n" | \
  15. while read -r line; do
  16. DATE=${line:0:10}
  17. FILE=${line:12}
  18. echo "<url>"
  19. echo " <loc>${URL}${FILE}</loc>"
  20. echo " <lastmod>$DATE</lastmod>"
  21. echo " <changefreq>$FREQ</changefreq>"
  22. echo "</url>"
  23. done
  24. # print foot
  25. echo "</urlset>"