Kategorie: System administration


Vim settings per directory

When hacking on b2evolution using vim, I often forget to ":set noet" (to not expand tabs) and it's really annoying to change this global setting everytime I open a b2evo related file.

According to the mantra, to search for a shortcut when a task becomes repetitive, I've finally searched for it and found a plugin, which looks for _vimrc_local.vim files (in the parent directories (and $HOME)).

Now, I can have a single _vimrc_local.vim file in the directory where all my b2evo related directories/branches reside - and override my global settings therein; It gets sourced/executed whenever I'm opening a file "below".

For more information see the Question on Stack Overflow and the actual plugin by Luc Hermitte. Thanks! :)

Update: as noted on Reddit, you could also use the following code in a vimrc file (e.g. ~/.vimrc):

:au! BufRead,BufNewFile /path/to/project/* setlocal noet

I still like the approach of having local override files in the directory structure though, which might come in handy for projects: if somebody has installed the plugin already there's no need to edit any .vimrc file (if the project ships the _vimrc_local.vim file in the project's root directory).


Clean URLs with lighttpd

To get clean URLs (e.g. for permalinks) in Lighttpd, you have to use the magnet module (lighttpd-mod-magnet in Ubuntu/Debian), and a Lua script.

I've created a file /etc/lighttpd/rewrite-to-docroot.lua:

if (not lighty.stat(lighty.env["physical.path"])) then
    lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. "index.php"

And enabled it using:

magnet.attract-physical-path-to = ("/etc/lighttpd/rewrite-to-docroot.lua")

This simulates the following mod_rewrite snippet known from Apache:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Previously I was using a tricky method, which would use the 404 handler ("server.error-handler-404 = /index.php"), but this caused missing GET params (as documented in the Lighttpd FAQ).
As a result, paged browsing of categories and tags wasn't possible.


Neuer Webserver

Seit nun schon fast einer Woche ist der neue Server, auf dem auch hahler.de läuft, online. Nicht ganz ohne Probleme (z.B. Proxy-Probleme über HTTPS), aber nun läuft es sehr rund, mit nur noch kleinen Änderungen hier und da.
Der alte Server wurde zum 01.05. gekündigt, während der neue - aufgrund von offenbar großer Nachfrage, bis Mitte April auf sich warten liess.

Es handelt sich dabei um den "DS 5000" von Hetzner (AMD Athlon 64 X2 5600+ Dual Core, 4GB RAM, 2 x 400 GB SATA II).

Ich setze dort OpenVZ zur Virtualisierung ein. Dies erlaubt es sehr schön und einfach virtuelle Maschinen/Umgebungen zu erstellen, so dass z.B. der Mailserver in einem eigenen Container/"Rechner" läuft. Das erhöht die Sicherheit (Angriffe, Ausfall) erheblich und erlaubt es, Dienste voneinander abzugrenzen.

Da die Zeit zum Ende des Monats (und besonders am letzten Tag) sehr knapp wurde, habe ich aber einen Großteil des alten Servers einfach als ganzes in einen solchen Container gesteckt. Diesen werde ich im Laufe der nächsten Wochen dann "zerstückeln" - soweit es sich anbietet und erforderlich ist.

Wer Interesse an System- und Statusinformationen hat, kann sich die von Munin erstellten Graphiken anschauen (mittlerweile durch Passwort geschützt). Hier kann man ganz gut die einzelnen Container anschauen/erkennen.

Das nur soweit zur Information und nun viel Spass mit einem viel leistungsfähigerem Server.. :)


Track changes to /etc (configuration files) with etckeeper

I'm currently setting up my new dedicated server and one of the first packages I've installed there has been etckeeper, to keep track of any changes to files in the etc (configuration) directory.

Etckeeper supports various VCS (version control systems), namely Git, Mercurial and bzr.
Bzr support is available in Ubuntu since "Hardy".

I've chosen to use "bzr". If you want to stick to the default (git), just leave out the bzr related stuff:

# Install etckeeper and bzr:
sudo apt-get install etckeeper bzr

# Read the fine documentation:
zless /usr/share/doc/etckeeper/README.gz

Quick walkthrough:

# Edit the config, chose the VCS to use:
sudo sensible-editor /etc/etckeeper/etckeeper.conf
=> VCS=bzr

# Init the repository:
sudo etckeeper init

# Verify that the file list is OK and commit:
cd /etc
sudo bzr commit -m "Initial checkin"

Now, whenever you use "apt" to install or remove programs, it will commit any changed files before and after the action (if there are any changes - not all packages install files into /etc).

Because "/etc" is now a regular repository, you can also manually commit any changes there, e.g. when editing some configuration file.
If you don't manually commit any changes, they will get picked up during the next run of apt automatically.

This is of course highly recommended for Desktop systems, too: you can always look up what changes to the system configuration have been done (including the exact time when you or somebody else has installed a particular package).

Give it a try, it won't hurt :)

Update: Thierry Carrez has written some chronicle articles about etckeeper