1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# Cgit with gitolite and caddy
## Setup
Install dependencies.
# apt install cgit python-is-python3 python3-pygments python3-markdown docutils-common groff perl
Make a git user.
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
Allow ssh passwordless login.
usermod -p '*' username
## Gitolite
Install the [gitolite](https://gitolite.com/gitolite/install.html) package from the repository directly.
### Configuration with cgit
Configuration of gitolite is done by modifying `$HOME/.gitolite.rc`.
To work correctly with cgit, gitweb and cgit configuration options need to work with gitolite.
Change:
GIT_CONFIG_KEYS => '',
To:
GIT_CONFIG_KEYS => '.*',
To have permissions work correctly,
Change:
UMASK => 0077,
To:
UMASK => 0027,
In the `ENABLE` field, add gitweb and cgit to the list.
### Usage
Detailed usage of gitolite can be found [here](https://gitolite.com/gitolite/basic-admin.html)
### Repository ignore
After cgit is configured, cgit can be told to ignore a repo with this syntax.
repo gitolite-admin
config cgit.ignore=1
### Adding Hooks to gitolite
This [page](https://gitolite.com/gitolite/cookbook#adding-other-non-update-hooks) details how to add hooks to your repositories.
Example hook that updates a website every git push. Make sure this directory is owned by git.
#!/bin/sh
GIT_WORK_TREE=/desired/website/directory git checkout -f
## Cgit
### Running cgit with caddy
Install the [fcgiwrap](https://packages.debian.org/bookworm/fcgiwrap) package.
Create a systemd service that wraps cgit with FastCGI.
# systemctl edit --full --force cgit.service
<!-- tsk -->
[Unit]
Description=CGI web interface to the Git SCM
After=network.target
[Service]
Type=exec
ExecStart=fcgiwrap -f -p "/usr/lib/cgit/cgit.cgi" -s tcp:127.0.0.1:8999
[Install]
WantedBy=multi-user.target
<!-- tsk -->
# systemctl start cgit
Add cgit configuration to caddy.
git.joshuayun.com {
handle_path /cgit-css/* {
root * /usr/share/cgit/
file_server
}
handle {
reverse_proxy localhost:8999 {
transport fastcgi {
env DOCUMENT_ROOT /usr/lib/cgit/
env SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi
}
}
}
}
## Cgit configuration
More detailed documentation can be found on the cgitrc(5) [manual](https://linux.die.net/man/5/cgitrc).
enable-git-config is used to allow for gitweb.* configurations in gitolite, e.g. description, owner.
enable-git-config=1
project-list sets where cgit looks for projects, this list is the one updated by gitolite
project-list=/home/git/projects.list
scan-path sets where the actual git repositories live
scan-path=/home/git/repositories
## References
[SixFoisNeuf](https://www.sixfoisneuf.fr/posts/setting-up-cgit-with-caddy2/) Used this blog to run cgit using fcgiwrap rather than a caddy plugin. The entire cgit with caddy section was using his work.
[Mateja Maric](https://matejamaric.com/blog/git-server/) Used this blog to help configure cgitrc, gitolite.rc
[Luke Hsiao](https://luke.hsiao.dev/blog/cgit-caddy-gitolite/) Used the git user creation command from this blog.
[Omar Polo (yumh)](https://www.omarpolo.com/post/cgit-gitolite.html) Used this blog to help configure cgitrc for hidden repos.
[Bryan Brattlof](https://bryanbrattlof.com/cgit-nginx-gitolite-a-personal-git-server/) Not much used here, kept as reference.
|