]> git.armaanb.net Git - bin.git/blobdiff - scoop-cgi
chrooter: drop script
[bin.git] / scoop-cgi
index 3b2aef5c0dc730f3602d9fe8d8e20936a3bb49d2..8f56f3e37790bf4459fd09b6fbbb886ccead4af1 100755 (executable)
--- a/scoop-cgi
+++ b/scoop-cgi
@@ -1,28 +1,43 @@
 #!/usr/bin/env sh
-# CGI script to get irc logs from scoop. Powers https://logs.armaanb.net.
+# CGI script to get irc logs from scoop. Powers https://irclogs.armaanb.net.
 
 channel=$(echo "$PATH_INFO" | awk -F / '{print $2}')
 if [ -z "$channel" ]; then
-               echo "Content-type: text/plain\n"
-               echo "Logged channels:"
-               cat /etc/scoop-cgi/channels
-               echo "
-url format: /channel/date
-date is optional, and defaults to the current day"
+               echo "Content-type: text/plain
+
+=================
+acheam's IRC logs
+=================
+
+logged channels
+---------------
+$(awk '{print "  * " $0}' /etc/scoop-cgi/channels)
+
+url format
+----------
+/channel/date
+date is optional, and defaults to the current day
+
+source
+------
+https://git.armaanb.net/bin/tree/scoop-cgi
+it's in the public domain!"
                exit 0
 fi
 
 channel=$(grep -x "$channel" /etc/scoop-cgi/channels)
 if [ -z "$channel" ]; then
                echo "Status: 404"
-               echo "Content-type: text/plain\n"
+               printf "Content-type: text/plain\n\n"
                echo "404. Channel not logged."
                exit 0
 fi
 
 time=$(echo "$PATH_INFO" | awk -F / '{print $3}' | xargs date -I -d)
+today=$(date -I)
+time=${time:-$today}
 db=$(cat /etc/scoop-cgi/database)
 
-echo "Content-type: text/plain\n"
-scoop -d "$db" -p "$channel" -D "${time:-now}" -F "%Y-%m-%d %H:%M:%S" \
+printf "Content-type: text/plain\n\n"
+PAGER=/dev/tty scoop -d "$db" -p "$channel" -D "$time" -F "%Y-%m-%d %H:%M:%S" \
                | awk '{$1=""; print substr($0, 2, length($0) - 1)}'