GitLab & LaTeX Builds

 

I like to write letters. I do not, however, enjoy wrangling Microsoft Word to ensure the same results each time; I use LaTex, where I can be guaranteed of consistent output.

As my library of past correspondence increases, I was looking for a way to implement version control as I drafted correspondence. Git was the obvious solution, and quite straightforward to set up. As I run a GitLab server on my Synology, I was happy storing a big backup of all of the history on a RAID device elsewhere in the house. But, I realised, it wasn't good practice to store the generated PDFs — the binary outputs — alongside their .tex files. At the same time, I had recently put together a fairly unique build server using GitLab CI for work. I was sure that I could make something that would be useful to me in this instance too.

...Read More

Email Submission to GitLab in a Synology Docker Image

I realise this is quite a specific post; this is mainly for posterity.

I have a Synology box running this docker image for GitLab. I also have some interest in configuring GitLab to receive emails from a specified mailbox, and create new issues upon receipt of an email.

This is possible with the docker image, using variables such as IMAP_USER as described in the gitlab docker page.

When this is all set up, the docker image fails to start its mail client. You will need to log in to the docker image, by first running docker ps. This will allow you to obtain the CONTAINER_ID of the docker image.

This will allow you to obtain a shell for the docker image, by typing docker exec -it CONTAINER_ID bash.

Then, on the docker image, run sudo -u git -H RAILS_ENV=production bin/mail_room start. This will start the mail_room, and if configured correctly, your docker image should start polling the configured IMAP server.

Reconnecting Ubiquiti OpenVPN connections

I have owned a Ubiquiti EdgeRouter Lite for more than a year, and continue to be impressed at its versatility. It's three gigabit ports that you can do almost any conceivable thing with. Currently I am using it to route all of my internet traffic through a VPN with Private Internet Access. This is straightforward to set up, but can be annoying for me (and even worse, the people I live with who don't have ssh), when the connection is dropped. A quick reboot is enough; but I wanted something automated.

Setup

Currently I have my config files in /config/auth/pia/melbourne2.ovpn. I created a shell script in /config/auth/pia/restart.sh:

#!/bin/bash

curl -s --connect-timeout 5 http://google.com > /dev/null
if [[ $? -eq 0 ]]; then
 echo "Online"
else
 pkill -f /usr/sbin/openvpn
 /usr/sbin/openvpn --daemon --verb 3 --writepid /var/run/openvpn-vtun0.pid --status /var/run/openvpn/status/vtun0.status 30 --config /config/auth/pia/melbourne2.ovpn --dev-type tun --dev vtun0
fi

chmod +x restart.sh will make this file executable.

This script looks to see if Google is contactable from the router, and uses this test to determine if the VPN is offline. If vtun0 is determined to be offline, then the openvpn process is killed, and restarted.

The router does have a a facility to set up scheduled tasks, but to me it was a little opaque. Login to your router as root, and edit the file /etc/crontab. Add the following line below the others:

* *     * * *   root    /config/auth/pia/restart.sh

The restart.sh script will be run every minute. Next time your internet drops out, you VPN connection should be re-established around a minute or so after your internet is.