76 lines
1.4 KiB
Bash
Executable File
76 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
|
|
baseDir="$(realpath "$(dirname "${0}")")"
|
|
date="$(TZ=UTC date -R)"
|
|
|
|
|
|
source "${baseDir}/website.conf"
|
|
|
|
shopt -s extglob
|
|
|
|
|
|
links=($(find -P "${webroot}/blog/" | awk '/index\.html/ && !/blog\/index\.html/ {sub(/index\.html/,"")sub(/.*\/blog/,"blog");print|"sort"}'))
|
|
|
|
|
|
menu="@(${links[0]}"
|
|
|
|
for ((i=1;i<${#links[@]};i++)); do
|
|
menu+="|${links[${i}]}"
|
|
done
|
|
|
|
menu+=")"
|
|
|
|
printf 'Select the link you wish to use\n'
|
|
|
|
select link in "${links[@]}"
|
|
do
|
|
case ${link} in
|
|
${menu})
|
|
break
|
|
;;
|
|
*)
|
|
printf \
|
|
'Invalid option\n'
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shopt -u extglob
|
|
|
|
title="$(cat "${webroot}/${link}/index.html" | awk '/<title>/{getline;print}' | sed 's|.*\[ ||g; s| \| easthighNerd \].*||')"
|
|
|
|
printf 'Description of blog post:\n'
|
|
read -r description
|
|
|
|
|
|
cat "${webroot}/blog/feed.rss" | sed '/<last.*$/Q' | tee "${webroot}/blog/feed.rss.tmp" &> /dev/null
|
|
|
|
cat << EOF | tee --append "${webroot}/blog/feed.rss.tmp" &> /dev/null
|
|
<lastBuildDate>
|
|
${date}
|
|
</lastBuildDate>
|
|
<item>
|
|
<title>
|
|
${title}
|
|
</title>
|
|
<link>
|
|
${websiteUrl}/${link}
|
|
</link>
|
|
<guid>
|
|
$(uuidgen)
|
|
</guid>
|
|
<pubDate>
|
|
${date}
|
|
</pubDate>
|
|
<description>
|
|
${description}
|
|
</description>
|
|
</item>
|
|
EOF
|
|
|
|
cat "${webroot}/blog/feed.rss" | sed '1,29d' | tee --append "${webroot}/blog/feed.rss.tmp" &> /dev/null
|
|
|
|
mv "${webroot}/blog/feed.rss.tmp" "${webroot}/blog/feed.rss"
|