Merge pull request 'Create mkwpost for creating announcements on the website' (#1) from pjals/vern-scripts:main into main

Reviewed-on: http://git.vern.cc/vern/scripts/pulls/1
This commit is contained in:
Arya K 2022-12-13 05:43:10 +00:00
commit bc9464f0ed
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