From 5aa2283f9951b3e035824b54bd0277ebf4394ffa Mon Sep 17 00:00:00 2001 From: Cullum Smith Date: Tue, 12 Nov 2024 23:50:18 -0500 Subject: add gitolite/cgit --- scripts/hostclass/git_server | 163 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 scripts/hostclass/git_server (limited to 'scripts') diff --git a/scripts/hostclass/git_server b/scripts/hostclass/git_server new file mode 100644 index 0000000..c7ac63d --- /dev/null +++ b/scripts/hostclass/git_server @@ -0,0 +1,163 @@ +#!/bin/sh + +: ${git_public_fqdn:="$fqdn"} +: ${git_basic_auth:='on'} +: ${gitolite_username:='s-gitolite'} +: ${gitolite_access_role:='gitolite-access'} +: ${gitolite_admin_role:='gitolite-admin'} +: ${cgit_clone_urls:="https://${fqdn} ssh://git@${fqdn}"} +: ${cgit_root_title:="${site} Git Repo"} +: ${cgit_root_desc:="Source code for various ${site} projects."} +: ${cgit_pygments_style:='xcode'} +: ${cgit_cache_size:='16000'} + +gitolite_dn="uid=${gitolite_username},${robots_basedn}" +git_keytab="${keytab_dir}/nginx.keytab" +git_https_cert="${nginx_conf_dir}/git.crt" +git_https_key="${nginx_conf_dir}/git.key" +gitolite_home=/usr/local/git +gitolite_client_keytab="${keytab_dir}/gitolite.client.keytab" +gitolite_fcgiwrap_socket=/var/run/fcgiwrap/gitolite.sock +cgit_cache_dir=/var/cache/cgit +cgit_fcgiwrap_socket=/var/run/fcgiwrap/cgit.sock +cgit_webroot=/usr/local/www/cgit + +# Install packages. +pkg install -y \ + python \ + nginx \ + cgit \ + gitolite \ + fcgiwrap \ + py${python_version}-pygments \ + py${python_version}-docutils \ + py${python_version}-markdown + +# Create ZFS dataset for gitolite repositories. +create_dataset -o "mountpoint=${gitolite_home}" "${state_dataset}/git" +zfs set \ + com.sun:auto-snapshot:hourly=true \ + com.sun:auto-snapshot:daily=true \ + com.sun:auto-snapshot:weekly=true \ + com.sun:auto-snapshot:monthly=true \ + "${state_dataset}/git" + +# Set ownership on gitolite dataset. +install_directory -o "$gitolite_local_user" -g "$gitolite_local_user" -m 0700 "$gitolite_home" + +# Add www user to git group, so it can read git repositories. +pw groupmod "$gitolite_local_user" -m "$nginx_user" + +# Create gitolite principal and keytab. +ldap_add "$gitolite_dn" <