2019-05-07 09:17:09 +02:00
|
|
|
|
#!/usr/bin/env sh
|
2019-09-12 09:15:34 +02:00
|
|
|
|
assert_tools () {
|
2019-09-17 16:34:04 +02:00
|
|
|
|
err=0
|
2019-09-12 09:15:34 +02:00
|
|
|
|
while test $# -gt 0; do
|
|
|
|
|
which $1 >/dev/null 2>/dev/null || {
|
2019-09-17 16:34:04 +02:00
|
|
|
|
>&2 echo "tool missing: "$1
|
|
|
|
|
err=$(( $err + 1 ))
|
2019-09-12 09:15:34 +02:00
|
|
|
|
}
|
|
|
|
|
shift
|
|
|
|
|
done
|
2019-09-17 16:34:04 +02:00
|
|
|
|
test $err -eq 0 || exit $err
|
2019-06-13 04:09:43 +02:00
|
|
|
|
}
|
2019-06-13 03:29:43 +02:00
|
|
|
|
test $# -eq 0 && {
|
2019-09-12 09:15:34 +02:00
|
|
|
|
dependencies="xsltproc"
|
|
|
|
|
assert_tools ${dependencies}
|
2019-06-13 03:29:43 +02:00
|
|
|
|
xsltproc --encoding utf-8 -o ds-feed.xml rss.xsl data.xml
|
|
|
|
|
xsltproc --encoding iso-8859-1 -o download.html download.xsl data.xml
|
|
|
|
|
xsltproc --encoding utf-8 -o index.html index.xsl data.xml
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
test "$1" = "sort" && {
|
2019-09-12 09:15:34 +02:00
|
|
|
|
dependencies="xsltproc"
|
|
|
|
|
assert_tools ${dependencies}
|
2019-06-13 03:29:43 +02:00
|
|
|
|
xsltproc --encoding utf-8 -o sorted.xml sort.xsl data.xml
|
|
|
|
|
mv -i sorted.xml data.xml
|
|
|
|
|
}
|
2019-09-17 16:34:04 +02:00
|
|
|
|
linkcheck () {
|
|
|
|
|
dependencies="curl uuid"
|
|
|
|
|
assert_tools ${dependencies}
|
|
|
|
|
tmpfile="/tmp/"$(uuid); curl https://ds.ccc.de/download.html > $tmpfile
|
|
|
|
|
for f in $(echo "download.html "$tmpfile); do
|
|
|
|
|
test -e $f || continue
|
|
|
|
|
for e in $(cat ${f}|sed 's/<a /\n<a /g'|grep -i " href="|cut -d"=" -f2|cut -d'"' -f2); do
|
|
|
|
|
status=$(curl --max-time 1 --head --silent --output /dev/null --write-out "%{http_code}" $e )
|
|
|
|
|
test $status -eq 200 && >&2 echo ${e}" – "${status}" OK" || >&2 echo ${e}" – "${status}" FAILED"
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
}
|
2019-09-12 09:15:34 +02:00
|
|
|
|
mirror_website () {
|
|
|
|
|
dependencies="wget"
|
|
|
|
|
assert_tools ${dependencies}
|
|
|
|
|
local url=$@
|
|
|
|
|
local domain=`expr "$url" : '^http[s]*://\([^/?]*\)'`
|
|
|
|
|
wget \
|
|
|
|
|
--recursive \
|
|
|
|
|
--no-clobber \
|
|
|
|
|
--page-requisites \
|
|
|
|
|
--html-extension \
|
|
|
|
|
--convert-links \
|
|
|
|
|
--restrict-file-names=windows \
|
|
|
|
|
--domains $domain \
|
|
|
|
|
--no-parent \
|
|
|
|
|
$url
|
|
|
|
|
}
|
2019-09-17 16:34:04 +02:00
|
|
|
|
newdataentry () {
|
|
|
|
|
dependencies="cat grep head cut date printf"
|
|
|
|
|
assert_tools ${dependencies}
|
|
|
|
|
err=0
|
|
|
|
|
fl=""
|
|
|
|
|
test $# -eq 0 && {
|
|
|
|
|
>&2 echo "determining entry based on data.xml.\n"
|
|
|
|
|
lastentry=$(cat data.xml |grep -i "<schleuder id="|head -1|cut -d'"' -f2)
|
|
|
|
|
newentry=$(( $lastentry + 1 ))
|
|
|
|
|
} || {
|
|
|
|
|
test "$1" = "help" && {
|
|
|
|
|
echo "prints a new data entry for a release of datenschleuder\n"
|
|
|
|
|
echo "release [options]\n"
|
|
|
|
|
echo "option\tdescription\n"
|
|
|
|
|
echo "number\tprint entry for release with custom number, default is the increment of the top entry in data.xml\n"
|
|
|
|
|
echo "date\tuse a unix timestamp for a custom date\n"
|
|
|
|
|
echo "teaser\tinclude teaser xml-message as last argument(s)\n"
|
|
|
|
|
echo "full example: `./gen.sh release 99 1568505600 Die Ausgabe 99 ist fertig.`"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
test $(( $1 * 1 )) -eq $1 && {
|
|
|
|
|
>&2 echo "custom entry for data.xml.\n"
|
|
|
|
|
newentry=$1; shift;
|
|
|
|
|
} || { echo "argument not a number."; exit 1; }
|
|
|
|
|
test $(( $1 * 1 )) -eq $1 && {
|
|
|
|
|
>&2 echo "custom datetime.\n"
|
|
|
|
|
datetime=$1; shift;
|
|
|
|
|
} || { datetime=0; } # remaining arguments should be teaser xml-message.
|
|
|
|
|
}
|
|
|
|
|
echo "<schleuder id=\"$newentry\">"
|
|
|
|
|
test $datetime -eq 0 && {
|
|
|
|
|
#~ datetime=$(LANG=en_US.utf8 date -u +"%a %d %b %Y %H:%M") # manual copy of known entries
|
|
|
|
|
datetime=$(LANG=en_US.utf8 date -u -R |rev|cut -d":" -f2-|rev) # RFC-5322-Format without seconds and TZ
|
|
|
|
|
} || {
|
|
|
|
|
datetime=$(LANG=en_US.utf8 date -d @${datetime} -u -R|rev|cut -d":" -f2-|rev)
|
|
|
|
|
}
|
|
|
|
|
echo "\t<date>"${datetime}" UT</date>" # custom format universal time
|
|
|
|
|
fn="ds"$(printf "%03d" $newentry)
|
|
|
|
|
for d in $(echo "covers pdfs epubs"); do
|
|
|
|
|
case "$d" in
|
|
|
|
|
covers) ffn=${d}"/"${fn}".jpg"; cover=$ffn ;;
|
|
|
|
|
pdfs) ffn=${d}"/"${fn}".pdf" ;;
|
|
|
|
|
epubs) ffn=${d}"/"${fn}".epub" ;;
|
|
|
|
|
#~ *) echo "file "${ffn}" not found, in "${d}"." ;;
|
|
|
|
|
esac
|
|
|
|
|
#~ echo $ffn
|
|
|
|
|
test -e ${ffn} && {
|
|
|
|
|
test "$d" = "covers" && {
|
|
|
|
|
echo "\t<image>"${cover}"</image>"
|
|
|
|
|
} || {
|
|
|
|
|
fs=$(stat -c %s ${ffn})
|
|
|
|
|
echo "\t<link filesize=\""${fs}"\">"${ffn}"</link>"
|
|
|
|
|
}
|
|
|
|
|
} || {
|
|
|
|
|
mfl=${ffn}"\n"
|
|
|
|
|
#~ echo "file "${ffn}" not found."
|
|
|
|
|
err=3
|
|
|
|
|
}
|
|
|
|
|
done
|
|
|
|
|
#~ echo "\t<preface></preface>" # not used on server yet
|
|
|
|
|
test $# -eq 0 && { teaser="" ; } || {
|
|
|
|
|
teaser=$@ ;
|
|
|
|
|
echo "\t<teaser>"${teaser}"</teaser>"
|
|
|
|
|
}
|
|
|
|
|
echo "</schleuder>"
|
|
|
|
|
test "$teaser" = "" && { >&2 echo "\nmissing teaser message."; }
|
|
|
|
|
test -e $cover || { >&2 echo "\nmissing cover."; }
|
|
|
|
|
test $err -gt 0 && { >&2 echo "\nmissing files:\n"${mfl}; }
|
|
|
|
|
}
|
|
|
|
|
newinfoentry () {
|
|
|
|
|
echo "not implemented yet.\n\nwill be similar to `release`."
|
|
|
|
|
}
|
2019-09-12 09:15:34 +02:00
|
|
|
|
# a mirror is useful for local testing with files
|
|
|
|
|
test "$1" = "mirror" && {
|
2019-09-17 16:34:04 +02:00
|
|
|
|
shift
|
|
|
|
|
>&2 echo "downloading the website may take quite some time."
|
2019-09-12 09:15:34 +02:00
|
|
|
|
mirror_website http://ds.ccc.de/
|
|
|
|
|
|
|
|
|
|
}
|
2019-09-17 16:34:04 +02:00
|
|
|
|
test "$1" = "linkcheck" && {
|
|
|
|
|
shift
|
|
|
|
|
linkcheck http://ds.ccc.de/
|
|
|
|
|
}
|
|
|
|
|
test "$1" = "release" && {
|
|
|
|
|
shift
|
|
|
|
|
newdataentry $@
|
|
|
|
|
}
|
|
|
|
|
test "$1" = "info" && {
|
|
|
|
|
shift
|
|
|
|
|
newinfoentry $@
|
|
|
|
|
}
|
2019-09-12 09:15:34 +02:00
|
|
|
|
#gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -q -o ds100-smaller.pdf ds100.pdf
|