Switch to ikiwiki

That is it, I switched to ikiwiki. I’m still able to use pandoc, have an automatic building and I’m able to do a lot more (tags, site-map, archives, …). I am using debian and the version of ikiwiki was a bit to old, so I rebuild it, form sid, and packages (for amd64) are available here :

ssh wrapper

Last week end I played around with ssh. I use a lot ssh daily and with ssh keys. I use keychain but I disabled the --ask option to have a startup quicker.

My need :

  • a way to enter ssh-key passphrase at the first connection.
  • a way to specify environment variable and run luit in case of a legacy server with a stupid encoding.

The following script currently does the stuff (and inform in case of luit use).

#!/bin/sh
# ssh-wrapper
# The main job of this wrapper is to load ssh-keys if not loaded
SELF=$(basename $0)

warn() {
echo "$(tput setaf 1)>$(tput bold)>$(tput sgr0) $1"
}

command -v ssh >/dev/null || {
echo "$SELF: Original ssh command no found..."
exit 1
}

# If no agent are running, there is nothing to do
if test -n "$SSH_AGENT_PID" && test -n "$SSH_AUTH_SOCK"; then
added_keys=$(ssh-add -l)
for pub_key in $HOME/.ssh/*.pub; do
private_key=$(echo $pub_key | sed 's/.pub//g')
# Get the fingerprint
#line="$(ssh-keygen -l -f $pub_key | sed 's/.pub//g')" # did it work ?
line="$(ssh-keygen -l -f $pub_key | awk '{ print $2 }')"
is_added=$(expr "$added_keys" : ".*$line.*")
if test $is_added -eq 0; then
# We have to add the key to the agent
ssh-add $private_key
fi
done
fi

# Parse .ssh/config in search of information.
# Let's give an example, let say I have the following .ssh/config
#
# Host foo
# User vincent
# IdentifyFile ~/.ssh/id_rsa
# Host bar
# User toto
# IdentifyFile ~/.ssh/id_rsa
# #-Option:TERM=xterm
# #-Option:ENCODING=ISO-8859-15
# Host foobar
# User titi
# #-Option:LANG=C
# #-Option:LC_MESSAGES=C
#
# If I want to connect to foobar, I want to use LANG=C and LC_MESSAGES=C when
# running ssh (or else). It run eval by default (something like a local export).
# If it contains ENCODING, this will try to run luit if present, and needed…
host=$1
pre_cmd=""
post_cmd=""
# Then some hacking to get commented line from config file
ssh_config=$(awk 'BEGIN \
{ RS = "Host"; FS = "#" } \
{ \
if ($1 ~ /'$host'/ && $1 !~ /ProxyCommand(.*)'$host'/) print }' $HOME/.ssh/config)
# ssh_config variable now contains the related Host config present in .ssh/config
for elt in $(echo $ssh_config | grep "#-"); do
var=$(echo $elt | awk 'BEGIN { FS=":" } { print $2 }')
if test $(expr "$var" : "ENCODING") -gt 0; then
# ENCODING is present, let's run luit if present (and needed)
encoding=$(echo $var | awk 'BEGIN { FS="=" } {print $2}')
if ! locale | grep -q "$encoding"; then
# the encoding requested is not the same
pre_cmd="luit -p -encoding $encoding"
enc_color="$(tput setaf 5)"
reset="$(tput sgr0)"
cenc_color="$(tput setaf 2)"
warn "Using $(tput sgr 0 1)luit${reset} to convert ${cenc_color}UTF-8${reset} to ${enc_color}$encoding${reset}"
fi
continue
fi
eval $var
done

$pre_cmd ssh $@

echo "$(tput setaf 2)<$(tput bold)<$(tput sgr0) Back on track (ssh $@)"
Posted

K.I.S.S me

K.I.S.S. stands for “Keep It Simple and Stupid”. And that is what I intend to keep on this website ; both in generating the static page and with the navigation.

A quick explanation :

  • The website is statically generated using pandoc1 and some custom, yet simple, python code and stored on a git repository. The building process of the site take place on the server, through git hooks. Basically I just need to have an editor (vim) and git on a computer to be able to update the website ; and git and pandoc on the server to be able to generate it. And as pandoc is package in debian I don’t even need to install some haskell stuff on the server, just apt-get install pandoc is enough.

  • The git repository is quite simple :

    • a building script (using python and fabric)
    • the content in the root folder
  • pandoc allows few metadatas in the header of the file (Title, Author and date). If I update the file, no need to update the Date in the metadata, the date information is already contained in the date of the file (that should be available on the browser, right ?)

  • Dead simple multilanguage support : name.__lang__.html (kiss-me.en.html).

  • Using the index feature of the web server (no need to generate an index file).

  • The only thing that is still missed is some atom/rss stuff.


  1. I am using pandoc as it supports a lot of input and outupt format; And the default pandoc format is a quite good extension of the markdown markup language.