scripts for my gemini capsule
Diffstat (limited to 'bookmark.sh')
| -rwxr-xr-x | bookmark.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bookmark.sh b/bookmark.sh new file mode 100755 index 0000000..b8d6a0d --- /dev/null +++ b/bookmark.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Place this script in your /cgi-bin to get your own bookmark writing script! + +# Have your host key put here for yourself. +authorized="SHA256:09CC327F3DDB21AE3BA4D0F38A6757236C8C2965A90539C640E14EB087955071 Gerbil@laptop" + +# Authorization guard. +if ! test "$REMOTE_USER"; then + printf '60 Try again with a client cert!\r\n' + exit +elif ! test "$(printf "$authorized" | grep "^$TLS_CLIENT_HASH ")"; then + printf '20 text/plain\r\n' + # Or, look, I did it for you! + cat "$0" | sed "s/^authorized=.*/authorized=\"$TLS_CLIENT_HASH $REMOTE_USER\"/g" + exit +fi + +# Input guard. +if ! test "$QUERY_STRING"; then + printf '10 Enter URL and title\r\n' + exit +fi + +dirname="$(dirname "$(realpath "$0")")" + +echo "=>$QUERY_STRING" >> "$dirname/../bookmarks.gmi" + +printf '30 ../bookmarks.gmi\r\n' |