Automatically install a signature for all Ximian Evolution accounts

This article was first written in April 2004 for
the BeezNest technical website (http://glasnost.beeznest.org/articles/118)
Create the file /etc/evolution-beeznest-signature.skeleton and adapt it to your needs [1]:
FULLNAME
BeezNest
Web: http://www.beeznest.net
E-mail: info@beeznest.net
Create the file /etc/evolution-gconf-signature.skeleton [2]:
<?xml version="1.0"?>
<signature name="beeznest"
format="text/plain"><filename>HOME/evolution/signatures/signature-0</filename></signature>
Use the following script, after creating the e-mail accounts.
#!/bin/bash
# Execute as user to add a personalized signature to every Evolution e-mail account

#set -x

SIGN_SKEL=/etc/evolution-beeznest-signature.skeleton
SIGN_GCONF_SKEL=/etc/evolution-gconf-signature.skeleton

# Check that signature skeleton already exists
if [ ! -r $SIGN_SKEL ]; then
        echo "No valid signature skeleton found in $SIGN_SKEL"
        exit 0
fi

# Check that signature GConf skeleton already exists
if [ ! -r $SIGN_SKEL ]; then
        echo "No valid signature GConf skeleton found in $SIGN_GCONF_SKEL"
        exit 0
fi

# Check HOME environment variable
if [ ! -z $HOME ]; then
        echo "$HOME is not set!"
        exit 0
fi

# Check default signature
if [ -d ~/evolution ]; then
        mkdir -p ~/evolution/signatures
else
        echo "~/evolution does not exist!"
        exit 0
fi

# Get user's full name from system
FULLNAME=`getent passwd | grep `id -un` | cut -f 5 -d: | sed -e "s/,/ /g"`
sed -e "s/FULLNAME/$FULLNAME/g" $SIGN_SKEL > ~/evolution/signatures/signature-0

# Add GConf entry
TEMPFILE=`mktemp`
sed -e "s/HOME/$HOME/g" $SIGN_GCONF_SKEL > $TEMPFILE
gconftool-2 --type list --list-type=string --set /apps/evolution/mail/signatures "[`cat $TEMPFILE`]"
rm $TEMPFILE

# Set as default for all accounts
TEMPFILE=`mktemp`
gconftool-2 --get /apps/evolution/mail/accounts | sed -s "s/default="-1"/default="0"/g" > $TEMPFILE
gconftool-2 --type list --list-type=string --set /apps/evolution/mail/accounts "`cat $TEMPFILE`"
rm $TEMPFILE

[1] FULLNAME will be automatically set to the user's full name, as defined on the system [2] yes, it is an XML file