💾 Archived View for alpha.lyk.so › systems › gemini › tinylog › post.sh captured on 2022-07-16 at 16:37:34.
⬅️ Previous capture (2022-04-28)
-=-=-=-=-=-=-
#!/usr/bin/env sh set -e echo "GEMINI_CERT GEMINI_KEY GEMINI_TINYLOG_LOCAL GEMINI_TINYLOG_REMOTE GEMINI_STATION_CSRF_TOKEN" | while read const; do if [ ! "$(eval "echo "$(echo "\$const")"")" ]; then >&2 echo "Required variable undefined: $const" exit 1 fi done stationpost="gemini://station.martinrue.com/$GEMINI_STATION_CSRF_TOKEN/post" # Mirror to station.martinrue.com if the post is not a tinylog reply if (! echo "$@" | head -n1 | grep -iq "^re: "); then urlencoded="$(echo -n "$@" | perl -MURI::Escape -ne 'print uri_escape($_)')" stationurl="$stationpost?$urlencoded" # Don't exceed the maximum post length on Station. urllen="$(printf "%s" "$stationurl" | wc -c)" if [ "$urllen" -gt "1024" ]; then >&2 echo "ERROR: The post URL exceeds 1024 bytes. The URL was $urllen bytes long. Trim down your post and try again." exit 1 fi gemget --cert $GEMINI_CERT --key $GEMINI_KEY $stationurl -o - > /dev/null fi ed "$GEMINI_TINYLOG_LOCAL" <<EOF /## i ## $(date -u +'%F %H:%M UTC') $@ . w q EOF # Setting SSH_AUTH_SOCK to an empty string for this command in order to bypass # the Ledger SSH agent, since we're using a key file rather than a hardware fob # to authenticate here. The user associated with this keyfile on the server can # *only* write to the tinylog file. SSH_AUTH_SOCK='' scp $GEMINI_TINYLOG_LOCAL $GEMINI_TINYLOG_REMOTE