gemini.cgi - dotfiles - These are my dotfiles. There are many like it, but these are mine.
 (HTM) git clone git://jay.scot/dotfiles
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
       gemini.cgi (1400B)
       ---
            1 #!/usr/bin/env sh
            2 # AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
            3 #         https://www.youtube.com/user/gotbletu
            4 # DESC:   gemini proxy to connect over http with w3m web browser
            5 # DEMO:   https://youtu.be/mfnCqn4qhL0
            6 # DEPEND: coreutils curl grep
            7 # REQD:   1. touch ~/.w3m/urimethodmap
            8 #         2. echo "gemini: file:/cgi-bin/gemini.cgi?%s" >> ~/.w3m/urimethodmap
            9 #         3. chmod +x ~/.w3m/cgi-bin/gemini.cgi
           10 #         4. sed -i 's@cgi_bin.*@cgi_bin ~/.w3m/cgi-bin:/usr/lib/w3m/cgi-bin:/usr/local/libexec/w3m/cgi-bin@g' ~/.w3m/config
           11 #         5. sed -i 's@urimethodmap.*@urimethodmap ~/.w3m/urimethodmap, /usr/etc/w3m/urimethodmap@g' ~/.w3m/config
           12 # CLOG:
           13 #         2021-07-30 use curl instead of ping
           14 
           15 # gemini://gempaper.strangled.net/mirrorlist/
           16 # gemini://simplynews.metalune.xyz
           17 # gemini://geminispace.info/search?tmux
           18 
           19 # remove gemini:// header
           20 QUERY_STRING=$(echo "$QUERY_STRING" | cut -d '/' -f3-)
           21 
           22 if [ "$(curl --connect-timeout 1 -s -I "https://portal.mozz.us/about" | head -n1 | grep 200 > /dev/null && echo $? )" = 0 ]; then
           23   echo "W3m-control: GOTO https://portal.mozz.us/gemini/$QUERY_STRING"
           24 elif [ "$(curl --connect-timeout 1 -s -I "https://proxy.vulpes.one" | head -n1 | grep 200 > /dev/null && echo $? )" = 0 ]; then
           25   echo "W3m-control: GOTO https://proxy.vulpes.one/gemini/$QUERY_STRING"
           26 else
           27   echo "W3m-control: GOTO https://gemproxy.koyu.space/$QUERY_STRING"
           28 fi