#!/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" <