Setting up Git using SourceHut (Part 2 actually getting GIT working)

So this is a follow up to my last post in which i was setting up selfhosted GIT using SourceHut.

In that post i got everything installed and mostly setup with the exception of being able to pull/push to any git repo. That has now been resolved with the help of a few people on the SourceHut mailing list.

The first “issue” was permissions on the logs for GIT. This was not preventing anything from working but was preventing the issues from being logged properly. So first step was to create the logs

touch /var/log/gitsrht-dispatch touch /var/log/gitsrht-keys touch /var/log/gitsrht-shell

Then set the permissions

chown git:git /var/log/git-*

Then i also changed the user for the git.sr.ht service by editing /usr/lib/systemd/system/git.sr.ht.service

Also ensure the folder hosting your repos is owned by the git user not the gitsrht user as my last post indicated.

sudo chown -R git:git /srv/gitrepos/

Next the root cause of the issue was that the git user did not have a proper shell defined. After i set it's shell to /bin/bash it started giving errors in the gitsrht-shell log.

First we had this:

2020/03/14 15:26:32 Looking up repo: pusher ID 0, repo path
/srv/gitrepos/~marcg/Initial_Repo
2020/03/14 15:26:32 Lookup failed: pq: SSL is not enabled on the server
2020/03/14 15:26:32 Looking up redirect
2020/03/14 15:26:32 Lookup failed: pq: SSL is not enabled on the server
2020/03/14 15:26:32 Repository not found.

I suspected the trouble was this Lookup failed: pq: SSL is not enabled on the server

A quick google search suggested adding this ?sslmode=disable to the connection string for the gitsrht database

which worked to remove that error on the next clone attempt the log showed

2020/03/14 15:32:12 Looking up repo: pusher ID 0, repo path
/srv/gitrepos/~marcg/Initial_Repo
2020/03/14 15:32:12 Lookup failed: sql: no rows in result set
2020/03/14 15:32:12 Looking up redirect
2020/03/14 15:32:12 Lookup failed: sql: no rows in result set
2020/03/14 15:32:12 Repository not found.

Which i was informed “could be caused by a faulty redis cache.” I had to ask for guidance here since i'm not familiar with interacting with redis.

I was told the following:

“You can list your keys like this: redis-cli -n 0 KEYS '*' (where the number after n is your redis cache number) And that should delete all keys: redis-cli -n 0 FLUSHDB”

So i did just that and that and now everything works. I am able to clone/push to my git install.

That's all for now

G

#tech #selfhost

Until next time. Stay safe!

G @mgrondin@youdabomb.social