diff options
author | glenda <glenda@9front.local> | 2021-01-14 19:18:16 +0000 |
---|---|---|
committer | glenda <glenda@9front.local> | 2021-01-14 19:18:16 +0000 |
commit | aacb3e890b1e719c15564b1272472a3c091da130 (patch) | |
tree | d00c0bcccdd206cb1a92d2580c576f2dc1699f74 | |
download | g9srv-aacb3e890b1e719c15564b1272472a3c091da130.tar.gz |
init commit
-rw-r--r-- | README | 17 | ||||
-rwxr-xr-x | install | 3 | ||||
-rwxr-xr-x | rfs | 52 | ||||
-rwxr-xr-x | tcp1965 | 2 |
4 files changed, 74 insertions, 0 deletions
diff --git a/README b/README new file mode 100644 index 0000000..c9239fe --- /dev/null +++ b/README @@ -0,0 +1,17 @@ +g9srv + +g9srv/rfs (read fs) +-w webroot the root of files to be served + +-m multi webroot allows you to host on multiple domaians for exaple: + +webroot/fulton.software/index.gmi + +webroot/plan9.fulton.software/index.gmi + +Coming soon: +Blog host + +Werc + +C lib diff --git a/install b/install new file mode 100755 index 0000000..b6d08f2 --- /dev/null +++ b/install @@ -0,0 +1,3 @@ +#! /bin/rc +mkdir -p /rc/bin/g9srv +cp rfs /rc/bin/g9srv diff --git a/rfs b/rfs new file mode 100755 index 0000000..7476e91 --- /dev/null +++ b/rfs @@ -0,0 +1,52 @@ +#! /bin/rc +#TODO add content type parser +cr= +fn header{ + echo $1 $2$cr +} + +fn filetype{ + filetype=`{file -m $1} + type=text/gemini + #TODO: expand + switch ($filetype){ + case image*: + type=$filetype + } + echo $type +} +webroot=./ +while(! ~ $#* 0) { + switch ($1) { + case -w + webroot=$2 + shift + case -m + mflag='yes' + case * + echo Usage: g9srv/fsr [-w webroot] [-m] + exit usage + } + shift +} +fullurl=`{read} +if(~ $mflag yes) + url=`{echo $fullurl | sed 's/gemini:\/\/// + s/ //'} +if not + url=`{echo $fullurl | sed 's/gemini:\/\/[0-9 a-z .]*// + s/ //'} +if(test -f $webroot$url){ + header 20 text/gemini + cat $webroot$url + exit 0 +} + +if(test -f $webroot$url/index.gmi) + header 20 text/utf8 + cat $webroot$url/index.gmi + exit 0 +} +header 51 'file not found' + + diff --git a/tcp1965 b/tcp1965 new file mode 100755 index 0000000..d81a2c9 --- /dev/null +++ b/tcp1965 @@ -0,0 +1,2 @@ +#!/bin/rc +exec tlssrv -c mycert /rc/bin/g9srv/rfs -w mywebroot |