summaryrefslogtreecommitdiff
path: root/blog/src/a/git_server_with_cgit.md
diff options
context:
space:
mode:
Diffstat (limited to 'blog/src/a/git_server_with_cgit.md')
-rw-r--r--blog/src/a/git_server_with_cgit.md65
1 files changed, 47 insertions, 18 deletions
diff --git a/blog/src/a/git_server_with_cgit.md b/blog/src/a/git_server_with_cgit.md
index da6464a..9d7ab44 100644
--- a/blog/src/a/git_server_with_cgit.md
+++ b/blog/src/a/git_server_with_cgit.md
@@ -13,16 +13,14 @@ Note that this is mostly for personal use, so there's no user/authentication con
## Prerequisites
-I might get tired of saying this (it's just copy paste, basically)... but similar as before (check my [website](https://blog.luevano.xyz/a/website_with_nginx.html) and [mail](https://blog.luevano.xyz/a/mail_server_with_postfix.html) entries):
+I might get tired of saying this (it's just copy paste, basically)... but you will need the same prerequisites as before (check my [website](https://blog.luevano.xyz/a/website_with_nginx.html) and [mail](https://blog.luevano.xyz/a/mail_server_with_postfix.html) entries), with the extras:
-* (This time, optional) A domain name if you want to have a "front end" to show your repositories. Got mine on [Epik](https://www.epik.com/?affid=da5ne9ru4) (affiliate link, btw).
- * With a **CNAME** for "git" and (optionally) "www.git", or some other name for your sub-domains.
-* A VPS or somewhere else to host. I'm using [Vultr](https://www.vultr.com/?ref=8732849) (also an affiliate link).
- * `ssh` configured.
- * (Optionally, if doing the domain name thingy) With `nginx` and `certbot` setup and running.
- * Of course, `git` already installed (it should be a must have always).
+* (Optional, if you want a "front-end") A **CNAME** for "git" and (optionally) "www.git", or some other name for your sub-domains.
+* An SSL certificate, if you're following the other entries, add a `git.conf` and run `certbot --nginx` to extend the certificate.
-## git server
+## Git
+
+[Git](https://wiki.archlinux.org/title/git) is a version control system.
If not installed already, install the `git` package:
@@ -74,20 +72,22 @@ systemctl start git-daemon.socket
systemctl enable git-daemon.socket
```
-You're basically done. Now you should be able to push/pull repositories to your server... except, you haven't created any repository in your server, that's right, they're not created automatically when trying to push. To do so, you have to do the following sequence (assuming you're "`cd`'ed" into the `/home/git` directory):
+You're basically done. Now you should be able to push/pull repositories to your server... except, you haven't created any repository in your server, that's right, they're not created automatically when trying to push. To do so, you have to run (while inside `/home/git`):
```sh
-mkdir {repo_name}.git
-cd {repo_name}.git
+git init --bare {repo_name}.git
+chown -R git:git repo_name.git
```
Those two lines above will need to be run each time you want to add a new repository to your server (yeah, kinda lame... although there are options to "automate" this, I like it this way).
-After that you can already push/pull to your repository. I have my repositories (locally) set up so I can push to more than one remote at the same time (my server, GitHub, GitLab, etc.), which is detailed [here](https://gist.github.com/rvl/c3f156e117e22a25f242).
+After that you can already push/pull to your repository. I have my repositories (locally) set up so I can push to more than one remote at the same time (my server, GitHub, GitLab, etc.); to do so, check [this gist](https://gist.github.com/rvl/c3f156e117e22a25f242).
+
+## Cgit
-## cgit
+[Cgit](https://wiki.archlinux.org/title/Cgit) is a fast web interface for git.
-This bit is optional if you only wanted a git server (really easy to set up), this is so you can have a web application. This is basically a copy paste of [Arch Linux Wiki: Cgit](https://wiki.archlinux.org/index.php/Cgit#Nginx) so you can go there and get more in-depth configurations.
+This is optionally since it's only for the web application.
Install the `cgit` and `fcgiwrap` packages:
@@ -102,7 +102,7 @@ systemctl start fcgiwrap.socket
systemctl enable fcgiwrap.socket
```
-Next, the way I configure `nginx` is creating a separate file `{module}.conf` (`git.conf` in this case) under `/etc/nginx/sites-available` and create a symlink to `/etc/nginx/sites-enabled` as stated in my [`nginx` setup entry](https://blog.luevano.xyz/a/website_with_nginx.html). Add the following lines to your `git.conf` file:
+Next, create the `git.conf` as stated in my [nginx setup entry](https://blog.luevano.xyz/a/website_with_nginx.html). Add the following lines to your `git.conf` file:
```nginx
server {
@@ -129,7 +129,6 @@ Now, all that's left is to configure `cgit`. Create the configuration file `/etc
```apache
css=/cgit.css
-source-filter=/usr/lib/cgit/filters/syntax-highlighting-edited.sh
logo=/cgit.png
enable-http-clone=1
@@ -155,6 +154,36 @@ repo.desc=These are my personal dotfiles.
...
```
-Otherwise you could let `cgit` to automatically detect your repositories (you have to be careful if you want to keep "private" repos) using the option `scan-path` and setup `.git/description` for each repository. I will add more to my actual configuration, but for now it is useful as it is. For more, you can check [cgitrc(5)](https://man.archlinux.org/man/cgitrc.5).
+Otherwise you could let `cgit` to automatically detect your repositories (you have to be careful if you want to keep "private" repos) using the option `scan-path` and setup `.git/description` for each repository. For more, you can check [cgitrc(5)](https://man.archlinux.org/man/cgitrc.5).
+
+By default you can't see the files on the site, you need a highlighter to render the files, I use `highlight`. Install the `highlight` package:
+
+```sh
+pacman -S highlight
+```
+
+Copy the `syntax-highlighting.sh` script to the corresponding location (basically adding `-edited` to the file):
+
+```sh
+cp /usr/lib/cgit/filters/syntax-highlighting.sh /usr/lib/cgit/filters/syntax-highlighting-edited.sh
+```
+
+And edit it to use the version 3 and add `--inline-css` for more options without editing `cgit`'s CSS file:
+
+```sh
+...
+# This is for version 2
+# exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null
+
+# This is for version 3
+exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
+...
+```
+
+Finally, enable the filter in `/etc/cgitrc` configuration:
+
+```apache
+source-filter=/usr/lib/cgit/filters/syntax-highlighting-edited.sh
+```
-Finally, if you want further support for highlighting, other compressed snapshots or support for markdown, checkout the optional dependencies for `cgit` and also the Arch Wiki goes in detail on how to setup highlighting with two different packages.
+That would be everything. If you need support for more stuff like compressed snapshots or support for markdown, check the optional dependencies for `cgit`.