Create mkwpost for creating announcements on the website

God forgive me
This commit is contained in:
pjals (Daniel) 2022-12-12 19:30:42 +02:00
parent 1a43d029c9
commit 61b8a85c4d
No known key found for this signature in database
GPG Key ID: 2CA877840D29E519
1 changed files with 20 additions and 0 deletions

20
tilserv/announce/mkwpost Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env -S bash -e
[[ -z "$1" ]] && {
printf "Usage: %s message [description]\n" "$0"
exit 1
}
HTML_ANNO=/var/log/announcements.html
SSI_ANNO=/var/log/ssi_anno.shtml
DATE="$(date --rfc-email -u)"
[[ -z "$2" ]] && {
MSG='\n\t\t<li>'"$DATE"' - <b>'"$1"'<\/b><\/li>'
sed -i "s/<ul>/<ul>$MSG/" $HTML_ANNO
printf "$(echo "$MSG" | sed 's/\\\//\//g' -)" > $SSI_ANNO
exit 0
}
MSG='\n\t\t<li>'"$DATE"' - <b>'"$1"'<\/b>\n<p>'"$2"'<\/p>\n\t\t<\/li>'
sed -i "s/<ul>/<ul>$MSG/" $HTML_ANNO
printf "$(echo "$MSG" | sed 's/\\\//\//g' -)" > $SSI_ANNO