Using GIT and VI together

A long while back I used vi together with rcs to manage files in /etc. This worked, but I found rcs to be clunky. So welcome to the 21st century and my git + vi script.

It is a wrapper around git, which will create a new git repository, add the file and commit it when changed.

The script will also expand $Hash$ to

$Hash: basename-of-file short-commit-hash epoch committer`

a typical example is

Read more →

Lazy client, part IV

Ok, so far I’ve created a cfengine setup that works. On my main host ’elektron’ I’ve created a /export/nfsroot/x86 directory. This holds the general files for the x86 Ubuntu lazy clients. With 2 scripts (see below) I can easily create a whole new x86 from scratch. Bringing up new lazy clients is even more easy, once the groundwork is there. I only need to do three things:

  • fix the DNS (forward and reverse)
  • fix the DHCP and add an ip address.
  • add this ip address to some cfengine file (2 in total)
  • optionally add some extra configuration in cfengine for this specific host.

Create a generic lazy client from scratch

There is one script that creates a new host in a chrooted environment, it starts a debootstrap and after that calls a follow-up script to finish the configuration for this host - after this step cfengine takes over. The second stage script takes care of setting up the sources.list for apt and a preliminary /etc/hosts file. Cfengine fixes everything else.

Read more →

Lazy client part III

In my ongoing effort to make my lazy client work I’ve embarked on the next phase of the project: Making a client boot from a generic NFS mounted root partition and then giving it its own /etc on a ramdisk.

This way I’m saving disk space and administration overhead on my server. The virtual /etc is provisioned by cfengine. This allows for small changes between the lazy clients while they still share the bulk of the rest of the files.

Read more →

CFengine: input file had no explicit version string

while playing with cfengine I kept seeing these messages:

Cfengine input file had no explicit version string

Well, I greped in the source of cfengine and this has helped me find the solution, in the file install.c we have the following:

3359 void VersionAuditFile()
3360 
3361 { char *sp;
3362 
3363 if (sp = GetMacroValue(CONTEXTID,"cfinputs_version"))
3364    {
3365    AUDITPTR->version = strdup(sp);
3366    }
3367 else
3368    {
3369    Verbose("Cfengine input file had no explicit version string\n");
3370    }
3371 }

(Line numbers are from VIM).

Read more →

Lazy client, part II

I want to quiet, full blown PC, without fans nor a harddisk in my living room. See my other blog about this subject

Currently I’m thinking about the following setup:

  • NFS4 root
  • some sort of configuration management

I wanted to use puppet, but after seeing it use more than 30% of my main memory – This is on a AMD64 Ubuntu server – I was ready to ditch it.

I’ve also have experience with cfengine, so I’m going to use that. In conjunction with svn. I’m going to store all my configs + cfengine files in one repository. The modus operandi will become:

Read more →

Bash loadable modules

Or how to create new builtins for use in bash. Short answer: you can, but it is not enabled by default (at least on my distribution, Ubuntu)

This is also something that is done much better in zsh.

Why do want this? SPEED!

Shell scripting is a very easy way to program, but forking all these helper programs takes a lot of time. So one way to speed up your shell program is to load these programs into the shell and making them a builtin.

Read more →

Slowly changing the background in XFCE

Google is always helpful of course, so I’ve found this blog entry on how to set the background in xfce.

It boils down to setting a jpg in XFCE’s backdrops.list and then reloading xfdesktop. Crude, but it works.

This can de done with the following command:

cat <<EOF > ~/.config/xfce4/desktop/backdrops.list
# xfce backdrop list
background.jpg
EOF

And then

xfdesktop --reload 

However when running from CRON it is more easy to do a killall -USR1 xfdesktop.

Read more →

The file system I want

Working on backup programs for almost a decade now, I’ve had plenty of time to think about file system wrt backups. Basically I want the following properties in a file system

  • online snapshots in a .snapshots directory (for instance).
  • the possibility to say the all those .snapshot directories must be mounted on a separate mount point.
  • to ability so say the .snapshot directories should be encrypted and send to remote server.

I think this is too much to ask…

Read more →

XFCE title less theme

After some switching I have now settled on XFCE. With Ubuntu XFCE sometimes does not start, this is a dbus issue in combination with gnome-screensaver (a race condition between the two). This sucks, but can be resolved easily with

apt-get remove gnome-screensaver

(There aren’t any interesting option anyway…)

So my XFCE is now up and running, time for some tweaking.

In the quest for precious vertical pixels (especially on the EeePC 701 I own) I decided I must remove those pesky title bars.

Read more →

Grrrr

Grrrrr

cd
rm -rf Desktop
mv Documents docs

I don’t want desktop environments messing with MY home directory.

Thank you.

Read more →

My favorite LaTeX preamble

I’ve written quite a few LaTeX documents during the last few years, but only recently I’m starting to discover very powerful new packages, like memoir and xelatex.

So I just wanted to share my “new” way of writing LaTeX docs.

First read the memoir class documentation. And the fontspec doc.

preamble

This now looks like

\documentclass{memoir}
\usepackage{eurosym}	%% for the EURO
\usepackage{fontspec}	
\usepackage{xltrxta}	%% \XeTeX if you need it

Usually this is hidden in one of my class files which implement a new look for a document. See the following articles for some examples

Read more →

truetype fonts in LaTeX the easy way (on Debian/Unbuntu)

Steps:

  1. Read: How to use nice fonts in LaTeX

  2. Install the software:

    sudo apt-get install texlive-xetex

    sudo apt-get install lcdf-typetools

The latter one is needed for otfinfo to determine the font family name.

  1. Read /usr/share/doc/texlive-doc/xetex/XeTeX-reference.pdf

  2. Use xelatex to create the pdf of your LaTeX documents

If you get the following error install the package lmodern

 LaTeX Error: File `lmodern.sty' not found.

Finally I can use truetype fonts in my LaTeX documentation. Sweet!

Read more →

SE Linux and BIND9

DSA 1617-1 a security update from Debian says they forgot to update the SE Linux policy that would allow BIND9 to randomize its source ports…

I always found SE Linux to be too complex for my needs, but now it turns out you can actually be more vulnerable when you run SE Linux.

I know enough.

Read more →

Fool the Dutch nameserver check

.nl employs a system for registering a domain name that works as follows:

  1. you setup a zone
  2. you register the zone name
  3. .nl checks the zone from your nameservers
  4. if the zone is found to be OK, your name is registered
  5. if it is not ok, you have to fix your zone or the name is already claimed (you can check that before hand)

This conflicts with how most ISPs work. Where one just updates the provisioning database and it (ideally) goes right to the registry to claim the name. Then after some time you “dump” the provisioning database on the network and automatically configure the zone for the customer.

Read more →

Not thin, not thick, but lazy

I’m trying to move my noisy server to the cellar I’m left with the question how do I cater for my desktop computer needs. I would be nice to have a thin client, but then you have the problem that local devices do not work: because you are actually working on the server, it needs to “know” somehow that you have locally inserted an USB disk. This sucks.

So how about a thick client, a client with enough power to run a full blown Linux distro. This works but has the following disadvantages:

Read more →

teletext (NL) script

Small script which display “teletekst” pages from the Dutch teletext (or the Belgium, but I’ve never used that).

I’m not the original author, but feel free to grab your copy.

#!/usr/bin/perl
#
# Dit scriptje laat de NOS teletext zien
#
# (c) 2001, 2002, 2003 by Bas Zoetekouw <bas@debian.org>
# All rights reserved.
# 
# Naar een idee van Wouter Bergmann-Tiest
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice and this list of conditions.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice and this list of conditions in the
#    documentation and/or other materials provided with the distribution.
#
#
## 2003-01-06: niew teletekst format
## 2003-01-06: kleurtjes
## 2003-01-06: meer html entities toegevoegd (dank Richard)
## 2003-01-22: VRT support
## 2003-02-07: kleur support aangepast

#use strict;

#my $SOURCE = "VRT"; 
my $SOURCE = "NOS"; 
my $LYNX;

foreach my $l (qw|/usr/bin/links /usr/bin/lynx lynx|) {
if (-x $l) {
    $LYNX=$l; last;
}
}

my $color = 1;
if ((scalar @ARGV > 0) && ($ARGV[0] eq "-m")) {
$color = 0;
shift @ARGV;
}

my %COLORS = ( "000000" => "\e[30m",  #black
	   "black"  => "\e[30m",  #black
	   "ff0000" => "\e[31m",  #red
	   "red"    => "\e[31m",  #red
	   "00ff00" => "\e[32m",  #green
	   "lime"   => "\e[32m",  #green
	   "0000ff" => "\e[34m",  #blue
	   "blue"   => "\e[34m",  #blue
	   "ffff00" => "\e[33m",  #yellow
	   "yellow" => "\e[33m",  #yellow
	   "ff00ff" => "\e[35m",  #magenta
	   "fuchsia"=> "\e[35m",  #magenta
	   "00ffff" => "\e[36m",  #cyan
	   "aqua"   => "\e[36m",  #cyan
	   "ffffff" => "\e[37m",  #white
	   "white"  => "\e[37m",  #white
	   "reset"  => "\e[0m");  #reset color
my %HTML   = ( "&quot;" => '"',
    "&shy;"  => "",
    "&lt;"   => '<',
    "&amp;"  => '&',
    "&gt;"   => '>');


sub display(\@) {
my @Output=@{(shift)};
my ($print, $last) = (0, 0);
foreach my $line (@Output) {
#	print "--> $line";
    ($print = 1) if ($line =~ s/^.*<pre>//i);
    ($last  = 1) if ($line =~ s/<\/pre>.*$//i);

    next unless ($print==1);

    if ($color==1) { 
	foreach (keys %COLORS) {
	    $line =~ s/COLOR=$_[^>]*>/>$COLORS{"$_"}/ig;
	} 
    }
    foreach (keys %HTML) {
	$line =~ s/$_/$HTML{"$_"}/ig;
    } 
    $line =~ s,<[^>]+>,,g;

    last if ($last == 1);

    print $line;

} 
print $COLORS{"reset"};
}

my ($Pagina, $SubPagina) = @ARGV;

$Pagina    = "100"  if  (scalar @ARGV == 0);
$SubPagina = "1"    if  (scalar @ARGV <= 1);  

my @Output = ("");
if ($SOURCE eq "NOS") {
$SubPagina = sprintf("%02i", $SubPagina);
@Output = `$LYNX -source 'http://teletekst.nos.nl/tekst/${Pagina}-${SubPagina}.html'`;
} elsif ($SOURCE eq "VRT") {
@Output = `$LYNX -source 'http://193.121.55.225/tt/tt.php?p=${Pagina}/${SubPagina}&g=0&s=0&r=0&x=1'`
}

display @Output;
Read more →

multihome setup in Linux

This is an older article that I’ve brought back to live This was original written at the time of Linux 2.6.0

So be ware!

update

As it turns out, the script below never did work correctly (see the bottom of this page for an updated version). The reason it did work for me was that sshn INET_2 never blocked outgoing port 25…until October the 8th. This was at the same time I was experimenting with linux2.6 (go figure). When sshn started to block port 25 outgoing, the script broke. For telnet session to port 25 it worked correctly, but actual sending of email was already done from a high port. This was always (incorrectly) routed through INET_2.

Read more →

Vim and GPG

This info can also be found on the Internet, but I thought I compile it here too.

Problem

You want to save something (say passwords) in a file and protect the file with a master password (say with your PGP/GPG key). This can be cumbersome unless you have vim.

The following examples will handle *.gpg files differently, vim will decrypt the file when opening it and encrypt the file when writing it. Also the use of a swap file is disabled.

Read more →

f()

You all, of course, know about the fc command. From bash’s help system:

fc: fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]

fc is used to list or edit and re-execute commands from the history list. FIRST and LAST can be numbers specifying the range, or FIRST can be a string, which means the most recent command beginning with that string.

Now I had the following problem: you have a file with shell commands in it. Next you want to select a few lines from this file to be executed in your running shell. A way to do this is:

Read more →

XFCE to Xmonad and back again

Well, after giving Xmonad a chance I’ve reverted back to XFCE. This time with a 1-pixel wide window decoration. Short story: I really like the tiling of Xmonad (or any other tiling window manager). But you do miss some flexibility if you really want to move a window. Also I needed a panel and system tray, which are available as third-party tools, but aren’t the real deal.

So back to XFCE.

Read more →

zsh prompt, part 2

Every now and then I get the ‘prompt-itch’ and then I need to tweak my prompt again :) Of course I’m very happy with the way my prompt was.

My idea of a good prompt is to be as short as possible and still be informative about your environment:

Only tell stuff I’m really interrested in and for the rest SHUT THE HELL UP!

So no date output in my prompt, If I want to know the time I will type date myself. I’m still thinking about leaving out the current hostname and current username… but for some reason I’ve become attached to seeing elektron (my hostname) on the screen.

Read more →

a new LaTeX style

I’ve created a new latex style to mimic some old school UNIX manuals I’ve been reading the past few months. It’s a very plain style that keeps out of your face. This in contrast with the blockbook style

This is how it looks:

screenshot from atroff rendered page

You can read about it a small howto doc. To use it, you will also need the class file.

UPDATE I’ve updated the style file so that the description lists will be indented with the same amount of space, no so more

Read more →

XFS corrupt again

Hmmm, this is the second time in 1 year that I had a corrupt filesystem on my raid partition. I saw no other option than mke2fs -j /dev/md7.

My first problem with XFS started on my fileserver, which only had 256 MB of memory. Turns out XFS was OOM-ing inside the kernel, this in turned messed up the filesystem. xfs_repair was also running out of memory. When I finally got enough virtual memory in this box xfs_repair was kind enough to segfault. Ok, shit happens, mkfs.xfs and try again.

Read more →

Giving GNOME the boot

The GNOME decadence thread got me thinking. What does GNOME give me? (I consider myself a hardcore UNIX user). Well… it gives a nice interface with a nice terminal implementation (gnome-terminal). Further more with the recent Ubuntu 8.04, it also provides

  • PulseAudio, never got that working btw, went back to ALSA.
  • Tracker, what the hell was ever wrong with locate? Never got that working, and when I did, it was dog slow.
  • I should be using evolution for emailing… no thanks! I’m a happy mutt user.
  • There is no support for VI-key bindings in GTK… (which is not gnome’s fault, but irritating none the less)

So I purged GNOME from my system and started using Xmonad, a tiling window manager. I’m still using GTK applications, because most of them still rule. But I’m happy that I’m leaving this whole GNOME business behind.

Read more →

git quick ref

I’m publishing this for my own future reference. A short usage guide on git for an ex-svn addict.

goal client server
init .git repo git init git init
start remote repo git clone ssh://server
add a file git add $file git add $file
commit the file git commit -a -m"log" git commit -a -m"log"
upload to server git push origin master
import remote changes git reset --hard
get changes from server git pull
Read more →

A popup from .procmailrc

Note: this is an older article that I’ve revived. Also note: in todays email flood I don’t know if such a popup is something you want to use…

#intro I’ve used gnubiff, xbiff and God knows what to provide a simple notify when receiving mail. But I wanted more. I want to be able to tweak certain settings, without going in to the source code of the application. Also the way mail notifiers mess with your mailbox is not something I particularly like.

Read more →