Browse Source

Added the Script.

Tino Reichardt 3 years ago
parent
commit
e69ddea011
2 changed files with 40 additions and 0 deletions
  1. 30 0
      sitemap.sh
  2. 10 0
      sitemap.sh.options

+ 30 - 0
sitemap.sh

@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# url configuration
+URL="https://mcmilk.de/"
+
+# begin new sitemap
+exec 1> sitemap.xml
+
+# print head
+echo '<?xml version="1.0" encoding="UTF-8"?>'
+echo '<!-- generator="Milkys Sitemap Generator, https://github.com/mcmilk/sitemap-generator" -->'
+echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
+
+# print urls
+IFS=$'\r\n' GLOBIGNORE='*' command eval "OPTIONS=($(cat $0.options))"
+find . -type f "${OPTIONS[@]}" -printf "%TY-%Tm-%Td %TH:%TM %p\n" | \
+while read -r line; do
+  # TIME is ignored...
+  DATE=${line:0:10}
+  TIME=${line:11:5}
+  FILE=${line:19}
+  echo "<url>"
+  echo " <loc>${URL}${FILE}</loc>"
+  echo " <lastmod>${DATE}</lastmod>"
+  echo " <changefreq>weekly</changefreq>"
+  echo "</url>"
+done
+
+# print foot
+echo "</urlset>"

+ 10 - 0
sitemap.sh.options

@@ -0,0 +1,10 @@
+-prune
+! -iname robots.txt
+! -iname sitemap.\*
+! -iname .\*
+! -path ./css/\*
+! -path ./js/\*
+! -path ./img/\*
+! -path ./tmp/\*
+! -path ./fonts/\*
+! -path ./stats/\*