5 CHATFILE="${CHATFILE:-/tmp/lets-chat.log}"
7 if [ "$GATEWAY_INTERFACE" != "CGI/1.1" ]; then
8 echo "not a cgi script?" >&2
12 if [ "$SERVER_PROTOCOL" != "GEMINI" ]; then
13 echo "not running over gemini?" >&2
17 # if [ "$REMOTE_USER" = "" ]; then
18 # printf "60 client certificate required\r\n"
22 if [ "$PATH_INFO" = "" ]; then
23 printf "20 text/gemini\r\n"
24 echo "# Let's chat over Gemini!"
26 echo "=> $SCRIPT_NAME/post Post a message"
27 echo "=> $SCRIPT_NAME/log Follow the conversation"
29 echo "=> https://git.omarpolo.com/blog/tree/resources/cgi/lets-chat source"
33 if [ "$PATH_INFO" = "/post" ]; then
35 exec printf "10 message to send: \r\n"
37 now="$(date '+%Y-%m-%d %H:%M')"
38 user="${REMOTE_USER##*/CN=}"
40 echo "$now ${user:-anon}: $@" >> "${CHATFILE}"
41 exec printf "30 $SCRIPT_NAME\r\n"
45 if [ "$PATH_INFO" = "/log" ]; then
46 printf "20 text/gemini\r\n"
47 exec tail -f "${CHATFILE}"
50 exec printf "51 not found\r\n"