Monday, 14 September 2009

KEYEXPIRED 1217637003

My debian box was unable to update for several months due to the following error when running apt-get update:

W: GPG error: http://mirror.noreply.org etch Release: The following signatures were invalid: KEYEXPIRED 1217637003 KEYEXPIRED 1217637003 KEYEXPIRED 1217637003 KEYEXPIRED 1217637003
W: You may want to run apt-get update to correct these problems

I particularly liked the way it suggests running apt-get update to fix the problem.

First off, if your error message has different key numbers then it's worth checking your debian distro keys are fine by running:

apt-key update

All the solutions I found to this specific key problem were in German but google translate saved the day.
The key in question is related to TOR, this line in /etc/apt/sources.list:

deb http://mirror.noreply.org/pub/tor etch main

The key used to sign the original packages has expired, to get the new one use:

gpg --keyserver keys.gnupg.net --recv 94C09C7F

gpg --export 94C09C7F | apt-key add -

Hopefully your apt-get update/upgrade should now work...

Wednesday, 5 August 2009

Random Gnome Desktop Image

After seeing a friend's mac doing random Desktop background images I was suprised to find that Gnome Desktop currently doesn’t ship with an option to do the same; so I wrote my own. It’s a short shell (bash) script which you configure with the name of a directory to pick a random image from, and the name of a file which you’ll tell Gnome Desktop is your background. The script then picks a random image from the directory and creates a symbolic link with the name you specified.

If you call the script from a your ~/.bash_profile it’ll pick a new desktop image every time you log on.

If you call the script from a cronjob it’ll change the image after the time period you specify, and will flip to the new image right away.

You don’t have to use the script for changing background images, you can use it any time you need a random file from a directory.

#!/bin/bash

# This script picks a random file from a directory you specify, and creates a symlink to it.
# Uses include random desktop image

#edit the next 2 lines to suit your setup
symlink="/home//Pictures/backgrounds/random.jpg"
sourcedir="/home//Pictures/backgrounds/random"

tmpfile="/tmp/randomimage.txt"

#get list of images
find $sourcedir -type f > $tmpfile

#pick a random one
imagecount=`wc -l $tmpfile | awk '{print $1}'`
chosennum=`expr \( $RANDOM \% $imagecount \) + 1`
chosenimg=`head -n $chosennum $tmpfile | tail -n 1`

rm $symlink
ln -s "$chosenimg" "$symlink"

rm $tmpfile