This commit is contained in:
Luke Smith 2021-09-14 14:07:45 -04:00
parent 208d31af3e
commit 8b00228bbf
No known key found for this signature in database
GPG Key ID: 4C50B54A911F6252
5 changed files with 317 additions and 3 deletions

151
cgit.html Normal file
View File

@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang=en>
<head>
<title>Setting up Cgit &ndash; LandChad.net</title>
<meta charset="utf-8" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel='stylesheet' type='text/css' href='style.css'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'>
</head>
<body>
<header>
<h1>Setting up Cgit</h1>
<img src="pix/cgit.svg" class="titleimg">
</header>
<main>
<p>
Once you have your server hosting your git repositories, you might want to allow others to browse
your repositories on the web. Cgit is a Free Software that allows browsing git repositories through
the web. </p>
<p>
Note that Cgit is a read-only frontend for Git repositories and doesn't have issues, pull requests
or user management. If that's what you want, consider installing Gitea instead.</p>
<h2>Installing cgit and fcgiwrap</h2>
<h3>Install fcgiwrap</h3>
<p>
NGINX doesn't have the capability to run CGI scripts by itself, it depends on an intermediate layer
like fcgiwrap to run CGI scripts like cgit:</p>
<pre><code>apt install fcgiwrap</code></pre>
<p>And now we can install cgit itself with:</p>
<pre><code>apt install cgit</code></pre>
<h2>Setting up NGINX</h2>
<p>
You should have an NGINX server running with a TLS certificate by now. Add the following configuration
to your server to pass the requests to Cgit, while serving static files directly:</p>
<pre><code>
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/nginx/<strong>git.example.org</strong>.crt;
ssl_certificate_key /etc/ssl/nginx/<strong>git.example.org</strong>.key;
server_name <strong>git.example.org</strong>;
root /usr/share/cgit ;
try_files $uri @cgit ;
location @cgit {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
fastcgi_param PATH_INFO $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
}
</code></pre>
<p>Then get NGINX to reload your configuration.</p>
<h2>Configuring cgit</h2>
<p>You've got cgit up and running now, but you'll probably see it without any style and without any repository.
To change this, we need to configure Cgit to our liking, by editing <code>/etc/cgitrc</code>.
</p>
<pre><code>
css=/cgit.css
logo=/cgit.svg
virtual-root=/
# Title and description shown on top of each page
root-title=<strong>Chad's git server</strong>
root-desc=<strong>A web interface to LandChad's git repositories, powered by Cgit</strong>
# The location where git repos are stored on the server
scan-path=/srv/git/
</code></pre>
<p>This configuration assumes you followed the <a href="/git">git hosting guide</a> and store your repositories
on the <code>/srv/git/</code> directory.</p>
<p>Cgit's configuration allows changing many settings, as documented on the cgitrc(5) manpage installed with
Cgit.</p>
<h3>Changing the displayed repository owner</h3>
<p>Cgit's main page shows each repo's owner, which is "git" in case you followed the git hosting guide, but you
might want to change the name to yours. Cgit shows the owner's system name, so you need to modify the git
user
to give it your name:</p>
<pre><code>
usermod -c "<strong>Your Name</strong>" git
</code></pre>
<h3>Changing the repository description</h3>
<p>Navigate to your bare repository on the server and edit the <code>description</code> file inside it</p>
<h3>Displaying the repository idle time</h3>
<p>To do this, we need to create a post-receive hook for each repository that updates the file cgit uses
to determine the idle time. Inside your repository, create a file <code>hooks/post-receive</code> and add
the following contents:</p>
<pre><code>
#!/bin/sh
agefile="$(git rev-parse --git-dir)"/info/web/last-modified
mkdir -p "$(dirname "$agefile")" &&
git for-each-ref \
--sort=-authordate --count=1 \
--format='%(authordate:iso8601)' \
>"$agefile"
</code></pre>
<p>And give it execution permissions with:</p>
<pre><code>chmod +x hooks/post-receive</code></pre>
<p>Next time you push to that repository, the idle time should reset and show the correct value.</p>
<h2>Contribution</h2>
<ul>
<li>Ariel Costas &ndash; <a href="https://costas.dev">website</a>, <a
href="https://costas.dev/donations/">donations</a></li>
</ul>
</main>
<footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><a
href="index.html">
<li><img src="pix/chad.gif" alt="chad"></li>
</a><a href="rss.xml">
<li><img src="pix/rss.svg" alt="RSS"></li>
</a><a href="pix/btc.png">
<li><img src="pix/btc.svg" alt="BTC"></li>
</a><a href="pix/xmr.png">
<li><img src="pix/xmr.svg" alt="XMR"></li>
</a><a href="https://github.com/lukesmithxyz/landchad">
<li><img src="pix/git.svg" alt="Github"></li>
</a></footer>
</body>
</html>

View File

@ -74,6 +74,7 @@ img { border: none ;}
<dt><a href="nextcloud.html"><img src="pix/nextcloud.svg"> Nextcloud</a></dt><dd>Setting up a Nextcloud Instance (file hosting and more)</dd>
<dt><a href="jitsi.html"><img src="pix/jitsi.svg" alt="Jitsi logo"> Jitsi</a></dt><dd>Free and easy video conferencing</dd>
<dt><a href="git.html"><img src="pix/git.svg"> git</a></dt><dd>Version control software on your own server</dd>
<dt><a href="cgit.html"><img src="pix/cgit.svg"> Cgit</a></dt><dd>A hyperfast web frontend for git repositories</dd>
<dt><a href="gitea.html"><img src="pix/gitea.svg"> Gitea</a></dt><dd>A fully-featured git and issue tracking site</dd>
<dt><a href="irc.html"><img src="pix/irc.svg"> IRC</a></dt><dd>Installing and managing a classic internet relay chat server</dd>
<dt><a href="rss-bridge.html">RSS Bridge</a></dt><dd>Creating RSS feeds for social media sites</dd>

58
pix/cgit.svg Normal file
View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 96 64">
<path id="cgit"
fill="#9e1212"
d="M 44.00,3.00
C 44.00,3.00 44.00,8.00 44.00,8.00
44.00,8.00 49.00,8.00 49.00,8.00
49.00,8.00 49.00,3.00 49.00,3.00
49.00,3.00 44.00,3.00 44.00,3.00 Z
M 60.00,9.00
C 60.00,9.00 60.00,16.00 60.00,16.00
60.00,16.00 56.00,16.00 56.00,16.00
56.00,16.00 56.02,19.98 56.02,19.98
56.02,19.98 59.98,20.00 59.98,20.00
59.98,20.00 60.00,37.00 60.00,37.00
60.00,39.99 59.69,44.16 61.74,46.57
64.65,50.00 76.35,50.00 79.26,46.57
81.32,44.16 80.99,40.00 81.00,37.00
81.00,37.00 76.06,37.06 76.06,37.06
76.24,39.83 76.03,41.32 75.03,42.59
73.56,44.38 66.99,45.07 65.50,41.50
64.15,38.26 64.96,24.11 64.96,19.98
64.96,19.98 81.09,20.00 81.09,20.00
81.09,20.00 81.00,16.00 81.00,16.00
81.00,16.00 65.00,16.00 65.00,16.00
65.00,16.00 65.00,9.00 65.00,9.00
65.00,9.00 60.00,9.00 60.00,9.00 Z
M 29.00,47.09
C 29.25,50.45 28.52,54.06 26.65,55.52
20.83,58.74 10.73,56.80 12.00,51.09
12.00,51.09 7.00,51.00 7.00,51.00
7.17,53.91 7.21,56.35 9.43,58.46
13.06,62.20 27.71,62.00 31.35,58.46
35.19,54.51 34.00,42.41 34.00,37.00
31.56,36.97 29.09,37.03 29.04,37.02
28.58,39.20 31.61,44.05 18.12,44.25
11.60,44.36 10.78,40.13 11.00,31.26
10.87,24.96 11.04,25.57 11.26,24.48
11.57,22.83 12.52,19.83 19.30,19.87
24.22,19.57 30.09,21.65 29.03,26.92
30.65,27.09 32.70,26.89 34.00,27.00
33.93,24.32 34.05,21.62 32.26,19.39
28.04,14.77 12.76,14.65 9.23,18.43
7.78,19.72 6.94,21.15 6.58,23.00
5.65,25.83 5.70,40.36 6.58,42.98
7.44,44.76 8.54,46.17 10.11,47.26
14.03,49.99 27.17,49.00 29.00,47.09 Z
M 44.00,16.00
C 44.00,16.00 44.00,49.00 44.00,49.00
44.00,49.00 49.00,49.00 49.00,49.00
49.00,49.00 49.00,16.00 49.00,16.00
49.00,16.00 44.00,16.00 44.00,16.00 Z
M 77.25,34.75M 18.25,44.69M 37.81,44.81M 32.26,50.57M 30.26,21.52M 29.09,20.70M 74.84,43.19" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

106
rss.xml
View File

@ -15,6 +15,110 @@
<!-- LB -->
<item>
<title>Setting up Cgit</title>
<guid>https://landchad.net/cgit.html</guid>
<link>https://landchad.net/cgit.html</link>
<pubDate>Tue, 14 Sep 2021 14:06:48 -0400</pubDate>
<description><![CDATA[
<header>
<h1>Setting up Cgit</h1>
<img src="pix/cgit.svg" class="titleimg">
</header>
<main>
<p>
Once you have your server hosting your git repositories, you might want to allow others to browse
your repositories on the web. Cgit is a Free Software that allows browsing git repositories through
the web. </p>
<p>
Note that Cgit is a read-only frontend for Git repositories and doesn't have issues, pull requests
or user management. If that's what you want, consider installing Gitea instead.</p>
<h2>Installing cgit and fcgiwrap</h2>
<h3>Install fcgiwrap</h3>
<p>
NGINX doesn't have the capability to run CGI scripts by itself, it depends on an intermediate layer
like fcgiwrap to run CGI scripts like cgit:</p>
<pre><code>apt install fcgiwrap</code></pre>
<p>And now we can install cgit itself with:</p>
<pre><code>apt install cgit</code></pre>
<h2>Setting up NGINX</h2>
<p>
You should have an NGINX server running with a TLS certificate by now. Add the following configuration
to your server to pass the requests to Cgit, while serving static files directly:</p>
<pre><code>
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/nginx/<strong>git.example.org</strong>.crt;
ssl_certificate_key /etc/ssl/nginx/<strong>git.example.org</strong>.key;
server_name <strong>git.example.org</strong>;
root /usr/share/cgit ;
try_files $uri @cgit ;
location @cgit {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
fastcgi_param PATH_INFO $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
}
</code></pre>
<p>Then get NGINX to reload your configuration.</p>
<h2>Configuring cgit</h2>
<p>You've got cgit up and running now, but you'll probably see it without any style and without any repository.
To change this, we need to configure Cgit to our liking, by editing <code>/etc/cgitrc</code>.
</p>
<pre><code>
css=/cgit.css
logo=/cgit.svg
virtual-root=/
# Title and description shown on top of each page
root-title=<strong>Chad's git server</strong>
root-desc=<strong>A web interface to LandChad's git repositories, powered by Cgit</strong>
# The location where git repos are stored on the server
scan-path=/srv/git/
</code></pre>
<p>This configuration assumes you followed the <a href="/git">git hosting guide</a> and store your repositories
on the <code>/srv/git/</code> directory.</p>
<p>Cgit's configuration allows changing many settings, as documented on the cgitrc(5) manpage installed with
Cgit.</p>
<h3>Changing the displayed repository owner</h3>
<p>Cgit's main page shows each repo's owner, which is "git" in case you followed the git hosting guide, but you
might want to change the name to yours. Cgit shows the owner's system name, so you need to modify the git
user
to give it your name:</p>
<pre><code>
usermod -c "<strong>Your Name</strong>" git
</code></pre>
<h3>Changing the repository description</h3>
<p>Navigate to your bare repository on the server and edit the <code>description</code> file inside it</p>
<h3>Displaying the repository idle time</h3>
<p>To do this, we need to create a post-receive hook for each repository that updates the file cgit uses
to determine the idle time. Inside your repository, create a file <code>hooks/post-receive</code> and add
the following contents:</p>
<pre><code>
#!/bin/sh
agefile="$(git rev-parse --git-dir)"/info/web/last-modified
mkdir -p "$(dirname "$agefile")" &&
git for-each-ref \
--sort=-authordate --count=1 \
--format='%(authordate:iso8601)' \
>"$agefile"
</code></pre>
<p>And give it execution permissions with:</p>
<pre><code>chmod +x hooks/post-receive</code></pre>
<p>Next time you push to that repository, the idle time should reset and show the correct value.</p>
<h2>Contribution</h2>
<ul>
<li>Ariel Costas &ndash; <a href="https://costas.dev">website</a>, <a
href="https://costas.dev/donations/">donations</a></li>
</ul>
</main>
]]></description>
</item>
<item>
<title>Self hosting</title>
<guid>https://landchad.net/selfhosting.html</guid>
@ -340,7 +444,7 @@ systemctl start calibre-server</code></pre>
</p>
<h2>Dependencies and Installation</h2>
<p>First, install some dependencies:</p>
<pre><code>apt install gpg apt-transport-https nginx python-certbot-nginx</code></pre>
<pre><code>apt install gpg apt-transport-https nginx python3-certbot-nginx</code></pre>
<p>Jitsi has its own package repository, so let's add it.</p>
<pre class=wide><code>curl https://download.jitsi.org/jitsi-key.gpg.key | gpg --dearmor &#62; /usr/share/keyrings/jitsi-keyring.gpg
echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' > /etc/apt/sources.list.d/jitsi-stable.list

View File

@ -51,10 +51,10 @@ Find the line that says <code>admins = { }</code> and to this we can specify one
</p>
<pre><code># To add one admin:
admins = { "chad@example.org" }
admins = { "<strong>chad@example.org</strong>" }
# We can add more than one by separating them by commas. (This file is written in Lua.)
admins = { "chad@example.org", "chadmin@example.org" }</code></pre>
admins = { "<strong>chad@example.org</strong>", "<strong>chadmin@example.org</strong>" }</code></pre>
<p>
Note that we have not created these accounts yet, we will do this <a href=#user>below</a>.