To get my feet wet with building Gemini Apps, I sought to run an existing one myself on my dev box.
This is a brain dump. It is late so I may go back and format this page properly.
The dev box is currently running Ubuntu 20.10
The first step was to pull the chosen app
I chose this app because the initial idea sucked me in. A hosted rss reader all within Gemini!
Afterwards I saw that development seems to be active and the go library that it uses is also very active.
I don't have any experience with go, but have been wanting to learn the language, so now is the perfect time.
First, I was going to build the app as is.
go build
The build failed, because go wasn't installed.
sudo apt-get install golang-go
Build again
Failed
package io/fs is not in GOROOT
As this was my first time with go I resorted to blindly searching the internet for a solution.
I stumbled on a reddit post that mentioned io/fs would be newly introduced
https://www.reddit.com/r/golang/comments/kwm5x9/a_github_gist_implementation_of_the_upcoming_iofs/
I then had the hunch that it could be an issue with my version of go.
In the end, yes it was due Ubuntu not having 1.16 in their default repository.
I ended up installing it manually.
https://www.kalilinux.in/2020/06/how-to-install-golang-in-kali-linux-new.html
go build
Success!
Now I had to deal with certs
cd /var/lib/gemini/certs
openssl req -x509 -out cert.pem -keyout key.rsa -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
Then I had to figure out the params to pass to the application
hostname := os.Args[1]
certpath := "/var/lib/gemini/certs"
cs := os.Args[2]
if len(os.Args) > 3 {
certpath = os.Args[3]
}
db, err := sql.Open("pgx", cs)
if err != nil {
log.Fatalf("Failed to open a database connection: %v", err)
}
First one was obviously hostname.
Second was more tricky. I knew cs was connection string, but I didn't know what pgx was.
I found pgx stood for postgresql here
http://go-database-sql.org/accessing.html
I found how to format the connection string here
https://pkg.go.dev/github.com/lib/pq
And installing postgresql was a breeze using this guide
The tables were generated using schema.sql
Finally I ran
./gemreader "localhost" "postgres://gemreader:gemreader@localhost/gemreader?sslmode=disable"
And I was able to successfully connect to the app via
//portal.mozz.us/gemini/localhost
/gemlog/