summaryrefslogtreecommitdiff
path: root/blog
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2021-04-03 23:15:38 -0700
committerDavid Luevano Alvarado <david@luevano.xyz>2021-04-03 23:15:38 -0700
commit2b94a020ccb78fa486691767e35110914fd53e8c (patch)
treedef0f1627e3eb02ca5ce2893a73819c30fb40826 /blog
parent1d3d721229e060c70ee28848d8b8d227e764990a (diff)
Add new blog entry and update gb stuff
Diffstat (limited to 'blog')
-rw-r--r--blog/dst/a/git_server_with_cgit.html238
-rw-r--r--blog/dst/a/mail_server_with_postfix.html6
-rw-r--r--blog/dst/index.html3
-rw-r--r--blog/dst/sitemap.xml3
-rw-r--r--blog/src/.files5
-rw-r--r--blog/src/a/git_server_with_cgit.md12
-rw-r--r--blog/src/index.md2
7 files changed, 255 insertions, 14 deletions
diff --git a/blog/dst/a/git_server_with_cgit.html b/blog/dst/a/git_server_with_cgit.html
new file mode 100644
index 0000000..d4304eb
--- /dev/null
+++ b/blog/dst/a/git_server_with_cgit.html
@@ -0,0 +1,238 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <script type="text/javascript" src="https://static.luevano.xyz/scripts/theme.js"></script>
+
+ <link id="code-theme-css" rel="stylesheet" type="text/css" href="https://static.luevano.xyz/hl/styles/solarized-dark.min.css">
+ <script type="text/javascript" src="https://static.luevano.xyz/hl/highlight.min.js"></script>
+ <script type="text/javascript">hljs.initHighlightingOnLoad();</script>
+ <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/fa/css/all.min.css">
+ <link id="theme-css" rel="stylesheet" type="text/css" href="https://static.luevano.xyz/css/dark.css">
+ <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/css/general_style.css">
+
+ <link rel="icon" href="https://static.luevano.xyz/fa/svgs/solid/dragon.svg">
+ <meta charset="utf-8">
+
+ <title>Luévano's Blog</title>
+ </head>
+
+ <body>
+ <div id="theme-switcher-container">
+ <i class="fas fa-sun"></i>
+ <label class="switch theme">
+ <input id="theme-switch" type="checkbox" onclick="toggleTheme()">
+ <span class="slider round"></span>
+ </label>
+ <i class="fas fa-moon"></i>
+ </div>
+
+ <header>
+ <ul class="menubar">
+ <li>
+ <a href="https://luevano.xyz/"><i class="fas fa-home" alt="Home"></i><span>Home</span></a>
+ </li>
+
+ <li>
+ <a href="https://blog.luevano.xyz/"><i class="fas fa-book-open" alt="Blog"></i><span>Blog</span></a>
+ </li>
+
+ <li><i class="fab fa-git" alt="Git"></i><span>Git</span>
+ <ul>
+ <li><a href="https://git.luevano.xyz/" target="_blank"><i class="fab fa-git-alt" alt="Git-alt"></i></a></li>
+
+ <li><a href="https://github.com/luevano" target="_blank"><i class="fab fa-github" alt="Github"></i></a></li>
+
+ <li><a href="https://gitlab.com/dluevano" target="_blank"><i class="fab fa-gitlab" alt="Gitlab"></i></a></li>
+ </ul>
+ </li>
+
+ <li><i class="fas fa-box-open" alt="Stuff"></i><span>Stuff</span>
+ <ul>
+ <li><a href="https://gb.luevano.xyz/"><i class="fas fa-gamepad" alt="Gameboy"></i><span>Gameboy</span></a></li>
+ </ul>
+ </li>
+
+ <li>
+ <a href="https://luevano.xyz/donate"><i class="fas fa-donate" alt="Donate"></i><span>Donate</span></a>
+ <ul>
+ <li><a href="https://paypal.me/dlvna"><i class="fab fa-paypal" alt="Paypal"></i><span>Paypal</span></a></li>
+ </ul>
+ </li>
+ </ul>
+ </nav>
+ </header>
+<h1>Create a git server and setup cgit web app (on Nginx)</h1>
+
+<p>My git server is all I need to setup to actually <em>kill</em> 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 <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server">git's guide on setting up a server</a> plus some specific stuff for (btw i use) Arch Linux (<a href="https://wiki.archlinux.org/index.php/Git_server#Web_interfaces">Arch Linux Wiki: Git server</a> and <a href="https://miracoin.wordpress.com/2014/11/25/step-by-step-guide-on-setting-up-git-server-in-arch-linux-pushable/">Step by step guide on setting up git server in arch linux (pushable)</a>).</p>
+
+<p>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.</p>
+
+<h2>Prerequisites</h2>
+
+<p>I might get tired of saying this (it's just copy paste, basically)&#8230; but similar as before (check my <a href="https://blog.luevano.xyz/a/website_with_nginx.html">website</a> and <a href="https://blog.luevano.xyz/a/mail_server_with_postfix.html">mail</a> entries):</p>
+
+<ul>
+<li>(This time, optional) A domain name if you want to have a &#8220;front end&#8221; to show your repositories. Got mine on <a href="https://www.epik.com/?affid=da5ne9ru4">Epik</a> (affiliate link, btw).
+
+<ul>
+<li>With a <strong>CNAME</strong> for &#8220;git&#8221; and (optionally) &#8220;www.git&#8221;, or some other name for your sub-domains.</li>
+</ul></li>
+<li>A VPS or somewhere else to host. I'm using <a href="https://www.vultr.com/?ref=8732849">Vultr</a> (also an affiliate link).
+
+<ul>
+<li><code>ssh</code> configured.</li>
+<li>(Optionally, if doing the domain name thingy) With <code>nginx</code> and <code>certbot</code> setup and running.</li>
+<li>Of course, <code>git</code> already installed (it should be a must have always).</li>
+</ul></li>
+</ul>
+
+<h2>git server</h2>
+
+<p>If not installed already, install the <code>git</code> package:</p>
+
+<pre><code class="language-sh">pacman -S git
+</code></pre>
+
+<p>On Arch Linux, when you install the <code>git</code> package, a <code>git</code> user is automatically created, so all you have to do is decide where you want to store the repositories, for me, I like them to be on <code>/home/git</code> like if <code>git</code> was a &#8220;normal&#8221; user. So, create the <code>git</code> folder (with corresponding permissions) under <code>/home</code> and set the <code>git</code> user's home to <code>/home/git</code>:</p>
+
+<pre><code class="language-sh">mkdir /home/git
+chown git:git /home/git
+usermod -d /home/git git
+</code></pre>
+
+<p>Also, the <code>git</code> user is &#8220;expired&#8221; by default and will be locked (needs a password), change that with:</p>
+
+<pre><code class="language-sh">chage -E -1 git
+passwd git
+</code></pre>
+
+<p>Give it a strong one and remember to use <code>PasswordAuthentication no</code> for <code>ssh</code> (as you should). Create the <code>.ssh/authorized_keys</code> for the <code>git</code> user and set the permissions accordingly:</p>
+
+<pre><code class="language-sh">mkdir /home/git/.ssh
+chmod 700 /home/git/.ssh
+touch /home/git/.ssh/authorized_keys
+chmod 600 /home/git/.ssh/authorized_keys
+chown -R git:git /home/git
+</code></pre>
+
+<p>Now is a good idea to copy over your local SSH public keys to this file, to be able to push/pull to the repositories. Do it by either manually copying it or using <code>ssh</code>'s built in <code>ssh-copy-id</code> (for that you may want to check your <code>ssh</code> configuration in case you don't let people access your server with user/password).</p>
+
+<p>Next, and almost finally, we need to edit the <code>git-daemon</code> service, located at <code>/usr/lib/systemd/system/</code> (called <code>git-daemon@.service</code>):</p>
+
+<pre><code class="language-ini">...
+ExecStart=-/usr/lib/git-core/git-daemon --inetd --export-all --base-path=/home/git --enable=receive-pack
+...
+</code></pre>
+
+<p>I just appended <code>--enable=receive-pack</code> and note that I also changed the <code>--base-path</code> to reflect where I want to serve my repositories from (has to match what you set when changing <code>git</code> user's home).</p>
+
+<p>Now, go ahead and start and enable the <code>git-daemon</code> socket:</p>
+
+<pre><code class="language-sh">systemctl start git-daemon.socket
+systemctl enable git-daemon.socket
+</code></pre>
+
+<p>You're basically done. Now you should be able to push/pull repositories to your server&#8230; 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 &#8220;<code>cd</code>'ed&#8221; into the <code>/home/git</code> directory):</p>
+
+<pre><code class="language-sh">mkdir {repo_name}.git
+cd {repo_name}.git
+</code></pre>
+
+<p>Those two lines above will need to be run each time you want to add a new repository to your server (yeah, kinda lame&#8230; although there are options to &#8220;automate&#8221; this, I like it this way).</p>
+
+<p>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 <a href="https://gist.github.com/rvl/c3f156e117e22a25f242">here</a>.</p>
+
+<h2>cgit</h2>
+
+<p>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 <a href="https://wiki.archlinux.org/index.php/Cgit#Nginx">Arch Linux Wiki: Cgit</a> so you can go there and get more in-depth configurations.</p>
+
+<p>Install the <code>cgit</code> and <code>fcgiwrap</code> packages:</p>
+
+<pre><code class="language-sh">pacman -S cgit fcgiwrap
+</code></pre>
+
+<p>Now, just start and enable the <code>fcgiwrap</code> socket:</p>
+
+<pre><code class="language-sh">systemctl start fcgiwrap.socket
+systemctl enable fcgiwrap.socket
+</code></pre>
+
+<p>Next, the way I configure <code>nginx</code> is creating a separate file <code>{module}.conf</code> (<code>git.conf</code> in this case) under <code>/etc/nginx/sites-available</code> and create a symlink to <code>/etc/nginx/sites-enabled</code> as stated in my <a href="https://blog.luevano.xyz/a/website_with_nginx.html"><code>nginx</code> setup entry</a>. Add the following lines to your <code>git.conf</code> file:</p>
+
+<pre><code class="language-nginx">server {
+ listen 80;
+ listen [::]:80;
+ root /usr/share/webapps/cgit;
+ server_name {yoursubdomain}.{yourdomain};
+ try_files $uri @cgit;
+
+ location @cgit {
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param QUERY_STRING $args;
+ fastcgi_param HTTP_HOST $server_name;
+ fastcgi_pass unix:/run/fcgiwrap.sock;
+ }
+}
+</code></pre>
+
+<p>Where the <code>server_name</code> line depends on you, I have mine setup to <code>git.luevano.xyz</code> and <code>www.git.luevano.xyz</code>. Optionally run <code>certbot --nginx</code> to get a certificate for those domains if you don't have already.</p>
+
+<p>Now, all that's left is to configure <code>cgit</code>. Create the configuration file <code>/etc/cgitrc</code> with the following content (my personal options, pretty much the default):</p>
+
+<pre><code class="language-apache">css=/cgit.css
+source-filter=/usr/lib/cgit/filters/syntax-highlighting-edited.sh
+logo=/cgit.png
+
+enable-http-clone=1
+# robots=noindex, nofollow
+virtual-root=/
+
+repo.url={url}
+repo.path={dir_path}
+repo.owner={owner}
+repo.desc={short_description}
+
+...
+</code></pre>
+
+<p>Where you can uncomment the <code>robots</code> line to let web crawlers (like Google's) to index your <code>git</code> web app. And at the end keep all your repositories (the ones you want to make public), for example for my <a href="https://git.luevano.xyz/.dots"><em>dotfiles</em></a> I have:</p>
+
+<pre><code class="language-apache">...
+repo.url=.dots
+repo.path=/home/git/.dots.git
+repo.owner=luevano
+repo.desc=These are my personal dotfiles.
+...
+</code></pre>
+
+<p>Otherwise you could let <code>cgit</code> to automatically detect your repositories (you have to be careful if you want to keep &#8220;private&#8221; repos) using the option <code>scan-path</code> and setup <code>.git/description</code> 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 <a href="https://man.archlinux.org/man/cgitrc.5">cgitrc(5)</a>.</p>
+
+<p>Finally, if you want further support for highlighting, other compressed snapshots or support for markdown, checkout the optional dependencies for <code>cgit</code> and also the Arch Wiki goes in detail on how to setup highlighting with two different packages.</p>
+
+<div class=timestamp>
+<hr>
+<p>Created: Sat, Mar 20, 2021 @ 22:58 MST; modified: Sun, Mar 21, 2021 @ 12:00 MST</p>
+</div>
+ <footer class="footer">
+ <i class="fas fa-envelope" alt="Email"></i>
+ Email
+ <a href="mailto:david@luevano.xyz">
+ david@luevano.xyz
+ </a>
+ <br>
+
+ <i class="fas fa-rss" alt="RSS"></i>
+ RSS
+ <a href="https://blog.luevano.xyz/rss.xml">
+ https://blog.luevano.xyz/rss.xml
+ </a>
+ <br>
+
+ <i class="fas fa-donate" alt="Donate"></i>
+ <a href="https://luevano.xyz/donate">Donate</a>
+ <a href="https://paypal.me/dlvna"><i class="fab fa-paypal" alt="Paypal"></i></a>
+ </footer>
+ </body>
+</html>
diff --git a/blog/dst/a/mail_server_with_postfix.html b/blog/dst/a/mail_server_with_postfix.html
index 2d5c178..9909882 100644
--- a/blog/dst/a/mail_server_with_postfix.html
+++ b/blog/dst/a/mail_server_with_postfix.html
@@ -78,12 +78,12 @@
<ul>
<li>Later we'll be adding some <strong>MX</strong> and <strong>TXT</strong> records.</li>
-<li>You also need a <strong>CNAME</strong> for &#8220;mail&#8221; and (optionally) &#8220;www.mail&#8221;, or whatever you want to call the sub-domains (although the <a href="https://tools.ietf.org/html/rfc2181#section-10.3">RFC 2181</a> states that it NEEDS to be an <strong>A</strong> record, fuck the police), to actually work and to get SSL certificate (you can also use the SSL certificate obtained if you created a website following my other notes on <code>nginx</code> and <code>certbot</code>).</li>
+<li>You also need a <strong>CNAME</strong> for &#8220;mail&#8221; and (optionally) &#8220;www.mail&#8221;, or whatever you want to call the sub-domains (although the <a href="https://tools.ietf.org/html/rfc2181#section-10.3">RFC 2181</a> states that it NEEDS to be an <strong>A</strong> record, fuck the police), to actually work and to get SSL certificate (you can also use the SSL certificate obtained if you created a website following my other notes on <code>nginx</code> and <code>certbot</code>) with <code>certbot</code> (just create a <code>mail.conf</code> for <code>nginx</code>, similar to how we created it in the website entry).</li>
</ul></li>
<li>A VPS or somewhere else to host. I'm using <a href="https://www.vultr.com/?ref=8732849">Vultr</a> (also an affiliate link).
<ul>
-<li>Also <code>ssh</code> configured.</li>
+<li><code>ssh</code> configured.</li>
<li>Ports 25, 587 (SMTP), 465 (SMTPS), 143 (IMAP) and 993 (IMAPS) open on the firewall (I use <code>ufw</code>).</li>
<li>With <code>nginx</code> and <code>certbot</code> setup and running.</li>
</ul></li>
@@ -551,7 +551,7 @@ systemctl enable spamassassin.service
<div class=timestamp>
<hr>
-<p>Created: Sat, Mar 20, 2021 @ 02:54 MST; modified: Sat, Mar 20, 2021 @ 03:06 MST</p>
+<p>Created: Sat, Mar 20, 2021 @ 02:54 MST; modified: Sat, Mar 20, 2021 @ 21:05 MST</p>
</div>
<footer class="footer">
<i class="fas fa-envelope" alt="Email"></i>
diff --git a/blog/dst/index.html b/blog/dst/index.html
index 2046246..17dcf86 100644
--- a/blog/dst/index.html
+++ b/blog/dst/index.html
@@ -63,7 +63,7 @@
</header>
<h1>Luévano's Blog</h1>
-<p>Welcome to my blog where I'll post whatever I'm pleased, ranging from rants to how-to's. Además, este pex va a estar en español e inglés porque quiero (no una mezcla en cada entrada, pero sí entradas completas en diferentes lenguajes).</p>
+<p>Welcome to my blog where I'll post whatever I please, ranging from rants to how-to's. Además, este pex va a estar en español e inglés porque quiero (no una mezcla en cada entrada, pero sí entradas completas en diferentes lenguajes).</p>
<h2>Articles</h2>
@@ -71,6 +71,7 @@
<h3>March 2021</h3>
+<li>Mar 20 - <a href=https://blog.luevano.xyz/a/git_server_with_cgit>Create a git server and setup cgit web app (on Nginx)</a></li>
<li>Mar 20 - <a href=https://blog.luevano.xyz/a/mail_server_with_postfix>Create a mail server with Postfix, Dovecot, SpamAssassin and OpenDKIM</a></li>
<li>Mar 18 - <a href=https://blog.luevano.xyz/a/website_with_nginx>Create a website with Nginx and Certbot</a></li>
<li>Mar 15 - <a href=https://blog.luevano.xyz/a/el_blog_ya_tiene_timestamps>Así es raza, el blog ya tiene timestamps</a></li>
diff --git a/blog/dst/sitemap.xml b/blog/dst/sitemap.xml
index afad9d9..cf81517 100644
--- a/blog/dst/sitemap.xml
+++ b/blog/dst/sitemap.xml
@@ -4,8 +4,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
-<url><loc>https://blog.luevano.xyz/index.html</loc><lastmod>2021-03-20</lastmod><priority>1.0</priority></url>
+<url><loc>https://blog.luevano.xyz/index.html</loc><lastmod>2021-03-25</lastmod><priority>1.0</priority></url>
<url><loc>https://blog.luevano.xyz/a/website_with_nginx.html</loc><lastmod>2021-03-18</lastmod><priority>1.0</priority></url>
+<url><loc>https://blog.luevano.xyz/a/git_server_with_cgit.html</loc><lastmod>2021-03-21</lastmod><priority>1.0</priority></url>
<url><loc>https://blog.luevano.xyz/a/el_blog_ya_tiene_timestamps.html</loc><lastmod>2021-03-15</lastmod><priority>1.0</priority></url>
<url><loc>https://blog.luevano.xyz/a/shell_scripting.html</loc><lastmod>2021-03-13</lastmod><priority>1.0</priority></url>
<url><loc>https://blog.luevano.xyz/a/sql_video_notes.html</loc><lastmod>2021-03-02</lastmod><priority>1.0</priority></url>
diff --git a/blog/src/.files b/blog/src/.files
index b6383f6..e524da2 100644
--- a/blog/src/.files
+++ b/blog/src/.files
@@ -1,8 +1,9 @@
-1615856381 0 ./index.md
+1615856381 1616720565 ./index.md
1616122695 0 ./a/website_with_nginx.md
+1616306327 1616353229 ./a/git_server_with_cgit.md
1615862784 0 ./a/el_blog_ya_tiene_timestamps.md
1615701454 0 ./a/shell_scripting.md
1614695711 0 ./a/sql_video_notes.md
1614431313 0 ./a/first_blog_post.md
1615701443 0 ./a/linux_video_notes.md
-1616234086 1616234777 ./a/mail_server_with_postfix.md
+1616234086 1616299559 ./a/mail_server_with_postfix.md
diff --git a/blog/src/a/git_server_with_cgit.md b/blog/src/a/git_server_with_cgit.md
index 975eaf7..d8a6037 100644
--- a/blog/src/a/git_server_with_cgit.md
+++ b/blog/src/a/git_server_with_cgit.md
@@ -1,6 +1,6 @@
-# Create a git server with cgit (nginx)
+# Create a git server and setup cgit web app (on Nginx)
-My git server is all I need to setup up 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](https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server) plus some specific stuff for (btw i use) Arch Linux ([Arch Linux Wiki: Git server](https://wiki.archlinux.org/index.php/Git_server#Web_interfaces) and [Step by step guide on setting up git server in arch linux (pushable)](https://miracoin.wordpress.com/2014/11/25/step-by-step-guide-on-setting-up-git-server-in-arch-linux-pushable/)).
+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](https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server) plus some specific stuff for (btw i use) Arch Linux ([Arch Linux Wiki: Git server](https://wiki.archlinux.org/index.php/Git_server#Web_interfaces) and [Step by step guide on setting up git server in arch linux (pushable)](https://miracoin.wordpress.com/2014/11/25/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.
@@ -70,8 +70,8 @@ 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):
```sh
-mkdir {project_name}.git
-cd {project_name}.git
+mkdir {repo_name}.git
+cd {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).
@@ -120,7 +120,7 @@ Where the `server_name` line depends on you, I have mine setup to `git.luevano.x
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):
-```
+```apache
css=/cgit.css
source-filter=/usr/lib/cgit/filters/syntax-highlighting-edited.sh
logo=/cgit.png
@@ -139,7 +139,7 @@ repo.desc={short_description}
Where you can uncomment the `robots` line to let web crawlers (like Google's) to index your `git` web app. And at the end keep all your repositories (the ones you want to make public), for example for my [*dotfiles*](https://git.luevano.xyz/.dots) I have:
-```
+```apache
...
repo.url=.dots
repo.path=/home/git/.dots.git
diff --git a/blog/src/index.md b/blog/src/index.md
index 2a871ee..475d807 100644
--- a/blog/src/index.md
+++ b/blog/src/index.md
@@ -1,5 +1,5 @@
# Luévano's Blog
-Welcome to my blog where I'll post whatever I'm pleased, ranging from rants to how-to's. Además, este pex va a estar en español e inglés porque quiero (no una mezcla en cada entrada, pero sí entradas completas en diferentes lenguajes).
+Welcome to my blog where I'll post whatever I please, ranging from rants to how-to's. Además, este pex va a estar en español e inglés porque quiero (no una mezcla en cada entrada, pero sí entradas completas en diferentes lenguajes).
## Articles