commit a5ca084067beb295b68fd7d6d3207afe0c6cb267 (patch)
parent 9cdd7c6298427fdad945f2567dd81c3472d59515
Author: alex <alex@garbash.com>
Date: Fri, 24 Sep 2021 22:49:09 -0400
git: Add notes on git hosting via stagit(1)
This turned out to be a fun evening hack :)
Shoutout to ~anthony for motivating me to go through with the
modifying stagit(1) approach instead of compromising with cgit
or the flat-tiered stagit approach!
Diffstat:
2 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/index.html b/index.html
@@ -1,3 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8"/>
+<meta name="viewport" content="width=device-width,initial-scale=1">
+</head>
+<body>
<h1>Game plan</h1>
@@ -9,7 +16,6 @@
<li>Set up IRC services (NickServ)</li>
<li>Start inviting people</li>
<li>Automate account creation</li>
-<li>git hosting via cgit</li>
<li>Homepage</li>
<li>wiki</li>
</ul>
@@ -22,4 +28,7 @@
<li><a href="notes/004-mail-server.txt">Email (SPF, DKIM, etc)</a></li>
<li><a href="notes/005-ssh-hardening.txt">SSH hardening</a></li>
<li><a href="notes/006-use-the-src.txt">Obtained the source code for the system</a></li>
+<li><a href="notes/007-git-coding.txt">Set up git hosting via stagit(1)</a></li>
</ul>
+</body>
+</html>
diff --git a/notes/007-git-coding.txt b/notes/007-git-coding.txt
@@ -0,0 +1,69 @@
+007-git-coding -- Fri Sept 24, 2021
+
+git(1) is one of my favorite tools. All good tilde's should host it!
+After all, tilde's are for sharing and what better way to share than
+publishing your code!
+
+Git Hosting
+-----------
+Out of the box, git supports hosting for users with accounts via ssh.
+You can clone like so:
+
+ user@host:path/relative/to/home
+or:
+
+ user@host:/abs/path/on/host
+
+For anonymous access, git-daemon(1) can be configured to serve over
+the git:// protocol. On OpenBSD, enable and start it with the path
+to the directories to serve:
+
+ $ rcctl enable gitdaemon
+ $ rcctl set gitdaemon flags "--base-path=/var/git"
+ $ rcctl start gitdaemon
+
+The last bit of the puzzle is of course the shared git layout! For
+git-daemon to work, we need all users to put their files under the
+same dir (/var/git). But, we want to prevent accidental clobbering
+via stray rm -rf, so we make a directory for each user and chown
+it to their account so soley they can access it:
+
+ /var/git/alex
+ .../www
+ .../config
+ /var/git/anthony
+ ...
+
+Then, for easy clone URLs, we ln(1) the dir into the home directory:
+
+ ln -s /var/git/$USER /home/$USER/git
+
+Now they can clone via $USER@garbash.com:git/REPO
+
+Web Hosting
+-----------
+git hosting is one thing, but these days everyone likes to show off
+their code in the browser for onlookers. Enter stagit(1).
+
+I tried cgit(1), one of the more popular git-frontends, but with httpd(8)'s
+chroot(8)-ing, it was kind of a pain to get the more advanced features.
+
+stagit(1) generates static HTML for individual repos, which is a nice
+balance of flexible and lightweight.
+
+The hardest part here was that I had to hack stagit(1) and stagit-index(1)
+to support our two-tiered directory layout (by default it only supports
+single directory layouts). This turned out to be not _that_ hard. See
+my fork [1] for the specifics.
+
+These HTML files are then generated on-the-fly at push time via git-hooks,
+specifically a post-receive hook.
+
+The whole process requires quite a bit of setup at repo-creation time
+(assigning ownership, description, clone-url, and the post-receive hook),
+so I rolled it all into a script globally available to our users: `newrepo`.
+That too is available via the system config files [2]. Give it a look!
+
+
+[1]: https://git.garbash.com/alex/stagit/
+[2]: https://git.garbash.com/alex/config/