fixup unison dir, auto-updates setup in separate repo
[distro-setup] / homepage-setup
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3 # This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
4
5 set -eE -o pipefail
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
7
8 domain=$1
9
10 if [[ ! $1 ]]; then
11 echo "$0: error: expected domain argument"
12 exit 1
13 fi
14
15 gitroot=/a/bin/githtml
16
17 type -P a2enmod &>/dev/null || pi apache2
18
19 acme-tiny-wrapper $domain
20
21 # debian has the package gitweb, which seems to mainly
22 # have some example apache config, and a minimal gitweb config.
23 # I'll just use the config as example and not use the package.
24 # It's example apache config seems to say we can use cgi or cgid,
25 # and googling cgid it seems a newer faster alternative.
26 sudo a2enmod cgid
27
28 # so, highlight is not highlighting my
29 pi highlight
30
31 # additional settings from browsing https://git-scm.com/docs/gitweb.conf
32 s dd of=/etc/gitweb.conf <<EOF
33 \$feature{'highlight'}{'default'} = [1];
34 # highlighting doesn't work on files without extension.
35 # I noticed in terminal "highlight file" won't do it (unknown file type)
36 # hightlight < file will do it, and it's online documentation
37 # suggests it reads shebang. Todo: file a bug for gitweb
38 # to make highlight read shebangs.
39 our \$projectroot = "$gitroot";
40 # not documented at https://git-scm.com/docs/gitweb.conf,
41 # but it's in the debian conf, so use it.
42 # directory to use for temp files.
43 \$git_temp = "/tmp";
44 push @git_base_url_list, "https://$domain/git";
45 EOF
46
47
48 apache-site - $domain <<EOF
49 # to run python script on my site:
50 <Directory /var/www/$domain/html>
51 # to run python scripts with cgi
52 Options +ExecCGI
53 AddHandler cgi-script .py
54 </Directory>
55
56
57 # All below is for gitweb + git-http-web.
58 # A simple builtin way to have a read only git website.
59 # I didn't find any significantly better alternatives out there.
60 SetEnv GIT_PROJECT_ROOT $gitroot
61 SetEnv GIT_HTTP_EXPORT_ALL
62
63 # note: cgi scripts can go anywhere into the filesystem,
64 # so there is no need to do a directory block for $gitroot
65
66 # fot git-http-web
67 <Directory /usr/lib/git-core>
68 AllowOverride None
69 Require all granted
70 </Directory>
71
72 <Directory /usr/share/gitweb>
73 Options +FollowSymLinks +ExecCGI
74 AddHandler cgi-script .cgi
75 </Directory>
76
77 # from man-git-http-backend, so git-http-web ang gitweb can both be used.
78 # it is instead of this:
79 # #ScriptAlias / /usr/lib/git-core/git-http-backend/
80 ScriptAliasMatch \\
81 "(?x)^/git/(.*/(HEAD | \\
82 info/refs | \\
83 objects/(info/[^/]+ | \\
84 [0-9a-f]{2}/[0-9a-f]{38} | \\
85 pack/pack-[0-9a-f]{40}\\.(pack|idx)) | \\
86 git-(upload|receive)-pack))\$" \\
87 /usr/lib/git-core/git-http-backend/\$1
88
89
90
91 # man-git-http-backend claims we should do this, but
92 # it causes no css/images to be displayed. Instead,
93 # just stick with the standard gitweb example directive
94 # from debian.
95 #ScriptAlias /git /usr/share/gitweb/gitweb.cgi/
96 Alias /git /usr/share/gitweb
97 EOF