From a5ca084067beb295b68fd7d6d3207afe0c6cb267 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 24 Sep 2021 22:49:09 -0400 Subject: [PATCH] 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! --- index.html | 11 ++++++++++- notes/007-git-coding.txt | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 notes/007-git-coding.txt diff --git a/index.html b/index.html index 564f9c6..0ae0cef 100644 --- a/index.html +++ b/index.html @@ -1,3 +1,10 @@ + + + + + + +

Game plan

@@ -9,7 +16,6 @@
  • Set up IRC services (NickServ)
  • Start inviting people
  • Automate account creation
  • -
  • git hosting via cgit
  • Homepage
  • wiki
  • @@ -22,4 +28,7 @@
  • Email (SPF, DKIM, etc)
  • SSH hardening
  • Obtained the source code for the system
  • +
  • Set up git hosting via stagit(1)
  • + + diff --git a/notes/007-git-coding.txt b/notes/007-git-coding.txt new file mode 100644 index 0000000..4fd06b0 --- /dev/null +++ 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/ -- libgit2 1.1.1