#!/bin/sh set -e # usage: ./sitemap.sh # Copyright 2019-2020 DistressNetwork° # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . urlencode() ( # urlencode old_lc_collate=$LC_COLLATE LC_COLLATE=C length="${#1}" i=1 while [ $i -le $length ] ; do c=$(expr substr "$1" $i 1) ; case $c in ([a-zA-Z0-9./~_-]) printf "$c" ;; (*) printf '%%%02X' "'$c" ;; esac ; true $((i=i+1)) ; done LC_COLLATE=$old_lc_collate ) echo ' ' > $2 echo "$(find -L $1 -type d | sort | sed -e 's;^\./;;' -e '\;/\(.git\|css\|error\|favicon\|fonts\|js\|media\);d' -e 's;$;/;')" | \ while IFS='' read -r data ; do DATE=$(grep "last-modified" ${data}/index.html | cut -f 4 -d \" | sed 's/ /T/' ) ; urlencode "$data" | sed -e 's;^;https://;' -e "s;$;${DATE};" ; printf "\n" ; done >> $2 echo '' >> $2 cat $2