From 5415f37e8da7615b524173f2bb6968be46128d20 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Tue, 8 Jun 2021 00:58:33 -0600 Subject: add 404 pages, edit entries and start skeleton for xmpp server entry --- blog/dst/a/git_server_with_cgit.html | 57 +++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'blog/dst/a/git_server_with_cgit.html') diff --git a/blog/dst/a/git_server_with_cgit.html b/blog/dst/a/git_server_with_cgit.html index 7259b42..64cd553 100644 --- a/blog/dst/a/git_server_with_cgit.html +++ b/blog/dst/a/git_server_with_cgit.html @@ -81,20 +81,13 @@

My git server is all I need to setup to actually kill my other server (I’ve been moving from servers on these last 2-3 blog entries), that’s why I’m already doing this entry. I’m basically following git’s guide on setting up a server plus some specific stuff for (btw i use) Arch Linux (Arch Linux Wiki: Git server and Step by step guide on setting up git server in arch linux (pushable)).

Note that this is mostly for personal use, so there’s no user/authentication control other than that of SSH. Also, most if not all commands here are run as root.

Prerequisites

-

I might get tired of saying this (it’s just copy paste, basically)… but similar as before (check my website and mail 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 and mail entries), with the extras:

-

git server

+

Git

+

Git is a version control system.

If not installed already, install the git package:

pacman -S git
 
@@ -125,14 +118,15 @@ ExecStart=-/usr/lib/git-core/git-daemon --inetd --export-all --base-path=/home/g
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):

-
mkdir {repo_name}.git
-cd {repo_name}.git
+

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):

+
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.

-

cgit

-

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 so you can go there and get more in-depth configurations.

+

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.

+

Cgit

+

Cgit is a fast web interface for git.

+

This is optionally since it’s only for the web application.

Install the cgit and fcgiwrap packages:

pacman -S cgit fcgiwrap
 
@@ -140,7 +134,7 @@ cd {repo_name}.git
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. Add the following lines to your git.conf file:

+

Next, create the git.conf as stated in my nginx setup entry. Add the following lines to your git.conf file:

server {
     listen 80;
     listen [::]:80;
@@ -161,7 +155,6 @@ systemctl enable fcgiwrap.socket
 

Where the server_name line depends on you, I have mine setup to git.luevano.xyz and www.git.luevano.xyz. Optionally run certbot --nginx to get a certificate for those domains if you don’t have already.

Now, all that’s left is to configure cgit. Create the configuration file /etc/cgitrc with the following content (my personal options, pretty much the default):

css=/cgit.css
-source-filter=/usr/lib/cgit/filters/syntax-highlighting-edited.sh
 logo=/cgit.png
 
 enable-http-clone=1
@@ -183,14 +176,32 @@ repo.owner=luevano
 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).

-

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.

+

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).

+

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:

+
pacman -S highlight
+
+

Copy the syntax-highlighting.sh script to the corresponding location (basically adding -edited to the file):

+
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:

+
...
+# 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:

+
source-filter=/usr/lib/cgit/filters/syntax-highlighting-edited.sh
+
+

That would be everything. If you need support for more stuff like compressed snapshots or support for markdown, check the optional dependencies for cgit.