#!/bin/mksh
# 2019-09-17T04:27+01:00 written by tilde.town/~alexandria

logfile="$HOME/.micro.log"
relays=("$HOME/public_gopher/picotoot.txt" "$HOME/public_html/picotoot.txt")
date="$(date -Im)"

[ "$1" == "show" ] && cat $logfile | head && exit 1

old=$(mktemp)
top=$(mktemp)

[ ! -e $logfile ] && touch $logfile

echo "$date" >> "$top"
cat >> "$top"
echo  "" >> $top

mv $logfile $old
cat $top $old > $logfile
rm $top $old

# copy to relays for public consumption
for file in ${relays[@]}; do
	cp $logfile $file
done