#!/bin/bash -l # Copyright (C) 2016 Ian Kelling # This program is under GPL v. 3 or later, see set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR domain=$1 if [[ ! $1 ]]; then echo "$0: error: expected domain argument" exit 1 fi gitroot=/a/bin/githtml type -P a2enmod &>/dev/null || pi apache2 acme-tiny-wrapper $domain # debian has the package gitweb, which seems to mainly # have some example apache config, and a minimal gitweb config. # I'll just use the config as example and not use the package. # It's example apache config seems to say we can use cgi or cgid, # and googling cgid it seems a newer faster alternative. sudo a2enmod cgid # so, highlight is not highlighting my pi highlight # additional settings from browsing https://git-scm.com/docs/gitweb.conf s dd of=/etc/gitweb.conf < # to run python scripts with cgi Options +ExecCGI AddHandler cgi-script .py # All below is for gitweb + git-http-web. # A simple builtin way to have a read only git website. # I didn't find any significantly better alternatives out there. SetEnv GIT_PROJECT_ROOT $gitroot SetEnv GIT_HTTP_EXPORT_ALL # note: cgi scripts can go anywhere into the filesystem, # so there is no need to do a directory block for $gitroot # fot git-http-web AllowOverride None Require all granted Options +FollowSymLinks +ExecCGI AddHandler cgi-script .cgi # from man-git-http-backend, so git-http-web ang gitweb can both be used. # it is instead of this: # #ScriptAlias / /usr/lib/git-core/git-http-backend/ ScriptAliasMatch \\ "(?x)^/git/(.*/(HEAD | \\ info/refs | \\ objects/(info/[^/]+ | \\ [0-9a-f]{2}/[0-9a-f]{38} | \\ pack/pack-[0-9a-f]{40}\\.(pack|idx)) | \\ git-(upload|receive)-pack))\$" \\ /usr/lib/git-core/git-http-backend/\$1 # man-git-http-backend claims we should do this, but # it causes no css/images to be displayed. Instead, # just stick with the standard gitweb example directive # from debian. #ScriptAlias /git /usr/share/gitweb/gitweb.cgi/ Alias /git /usr/share/gitweb EOF