blob: 5d0a42e3b6887316a7dbd6b4167888f7d2f4190c (
plain) (
blame)
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
32
33
34
|
#!/bin/bash
HOSTNAME=${HOSTNAME:-$(hostname)}
URL="https://$HOSTNAME/"
# values: always hourly daily weekly monthly yearly never
FREQ=${FREQ:-"weekly"}
generate(){
exec 1> sitemap.xml
# print head
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<!-- generator="https://git.xolatile.top/emil/sitemap-generator" -->'
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">'
# print urls
IFS=$'\r\n' GLOBIGNORE='*' command eval "OPTIONS=($(cat $0.options))"
find . -type f "${OPTIONS[@]}" -printf "%TY-%Tm-%Td%p\n" | \
while read -r line; do
DATE=${line:0:10}
FILE=${line:12}
echo "<url>"
echo "<loc>${URL}${FILE}</loc>"
echo "<lastmod>$DATE</lastmod>"
echo "<changefreq>$FREQ</changefreq>"
echo "</url>"
done
# print foot
echo "</urlset>"
}
generate
|