Linux AltGr shortcuts for Vietnamese characters

Writing Vietnamese correctly requires diacritics that aren’t commonly used in Western languages. Miss one out and you completely change the meaning of what you’re writing. As I frequently communicate in Vietnamese it’s important to be able to input diacritics, which is a bit of problem since Western keyboards don’t include them. On my own laptop I use IBus to allow me to switch into UniKey mode, but it’s a bit fiddly to set up, and it’s not an option when I’m using a different computer.

Recovering a Debian server after accidental deletion of /var directory

Today I had to recover a Debian server after the /var partition was accidentally deleted. All the user generated data (primarily website content and databases) was backed up, and I also had access to a backup copy of the installed package list as generated by dpkg --get-selections. The instructions below don’t go into full detail, but hopefully they will set you on the right track. They should also work for Ubuntu installs.

If this happens to you, don’t panic, and whatever you do, don’t shut down or reboot the server!

How to upgrade the firmware on an LSI MegaRAID SAS controller under Linux

In this post, I describe how to upgrade the firmware on an LSI MegaRAID SAS controller to the latest version. Upgrading the firmware is recommended before making certain changes, e.g. installing a battery backup unit. These instructions have been tested on an LSI MegaRAID SAS 9260-4i but should also work for other models using LSI’s 2108 chipset.

How to install Composer and Drush in a multi-user configuration

In this article I'll walk through how to set up Composer, Drupal 8 (or 9), and Drush in a way that means we can have multiple users running the same centralised version of Drush when appropriate (ie. when a Drupal site isn't set up as a Composer project, or a project doesn't include its own copy of Drush) which means that our team can keep using Drush seamlessly without having to install a separate copy of Composer and Drush for each user or each project on our servers. This approach should also make it easy to keep things up to date and change the configuration later on if needed.

Correctly setting the return path on emails sent by PHP

Email commonly includes the sender’s address in two places. The From header in the message body is the one that most people are aware of, and this is the address that email recipients see. However, the sending mail server also adds a Return-Path before the message body. Recipients don’t generally see this address, but it is important for two reasons. First, it is used in a number of anti-spam checks. Second, it’s the address that typically receives non-delivery reports if a message can’t be delivered for any reason.

Setting up a Let's Encrypt signed on-demand IKEv2 VPN on Debian/Ubuntu for iOS with username and password authentication

Here’s how to set up a VPN that has all these features:

  • Works natively on iOS and macOS
  • Doesn't require you to manage certificates or keys
  • Automatically connects when your device is online

It should also work on Windows*, and Android via the StrongSwan app, but I haven’t tested it. Please post about your experiences using this guide with other devices in the comments!

Configuring MySQL/MariaDB to work with SSL/TLS

MySQL has supported TLS for TCP/IP connections for some time now, but there are a number of subtleties involved in getting it working. If you need to allow remote access to your databases, you really ought to be using TLS to protect your login details and any confidential data that might be transferred. Here are the various steps required to enable TLS in MySQL on Debian and Ubuntu. Note that MySQL still refers to everything as SSL, but it’s more correct to call it TLS as SSL is deprecated these days. The same instructions also ought to work for MariaDB.

ProFTPd login successful but data connection refused

At some point in the last few months, ProFTPd stopped working on several of the servers we maintain. Since it was working before, we didn’t change any of the configuration files, and it stopped working on several servers independently, I’m guessing that this was due to a change in the default config of ProFTPd, or at least the Debian Jessie version of ProFTPd. There’s an easy workaround but not a real solution at time of writing.

The definitive guide to creating emails with attachments in Python 3

There is a lot of conflicting advice out on the internet about how best to construct an email with attachments using standard Python libraries. None of it explains why to do things in certain ways. Here is a definitive, tested bit of code that will create an email with attachments that will work correctly. I’m posting it here so I don’t need to spend any time working it all out again!