-#!/bin/bash -l
-# Copyright (C) 2016 Ian Kelling
-# This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
-
-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 <<EOF
-\$feature{'highlight'}{'default'} = [1];
-# highlighting doesn't work on files without extension.
-# I noticed in terminal "highlight file" won't do it (unknown file type)
-# hightlight < file will do it, and it's online documentation
-# suggests it reads shebang. Todo: file a bug for gitweb
-# to make highlight read shebangs.
-our \$projectroot = "$gitroot";
-# not documented at https://git-scm.com/docs/gitweb.conf,
-# but it's in the debian conf, so use it.
-# directory to use for temp files.
-\$git_temp = "/tmp";
-push @git_base_url_list, "https://$domain/git";
-EOF
-
-
-apache-site - $domain <<EOF
-# to run python script on my site:
-<Directory /var/www/$domain/html>
- # to run python scripts with cgi
- Options +ExecCGI
- AddHandler cgi-script .py
-</Directory>
-
-
-# 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
-<Directory /usr/lib/git-core>
- AllowOverride None
- Require all granted
-</Directory>
-
-<Directory /usr/share/gitweb>
- Options +FollowSymLinks +ExecCGI
- AddHandler cgi-script .cgi
-</Directory>
-
-# 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