Apt can’t see sources? Try changing the User Agent

If you are trying to use apt behind a corporate firewall, try changing the user agent apt is using with wget to load the package lists. By default it uses:

User-Agent: Debian APT-HTTP/1.3

which isn’t recognised by the filter.

1. Create and edit /etc/apt/apt.conf

sudo vi /etc/apt/apt.conf

2. Paste the following into the file:

  http::User-Agent "Mozilla/5.0 (Windows NT 5.1; rv:25.0) Gecko/20100101 Firefox/25.0";

3. Update apt

sudo apt-get update


Setting up Rasbmc (XBMC) on a Raspberry Pi

Raspberry Pi in Action

This is a cheap way to get a high quality and flexible media center sitting under (or in my case, behind) your TV.


From Windows:

  1. Download the installer
  2. Insert your SD card into the computer.
  3. Unzip and run the raspbmc-win32 installer.
  4. Once that is done, stick the card into the Pi and give it some power.
  5. Wait while it installs the root system (grab a coffee!) This should take about 15 minutes, then with a little luck the Pi will reboot twice, run it’s automatic updater, reboot again, then finally open into XBMC .
  6. Note down the IP that is assigned to the Pi as it flashes up, or work it out by checking your router.
  7. Set up your remote. I use Yatse on my Android devices. Otherwise plug in a keyboard or mouse. I’m assuming you can get some input sorted.
  8. Go Settings -> System -> Video -> Video Output and calibrate the TV (otherwise the left sidebar ends up off screen for me).
  9. Add your content. Go Video -> Files -> Files -> Add Videos…
  10. Click browse and choose your directory (root file system / media for me)
  11. Then choose the type of Video you are adding. I’m only adding home videos, but I imagine selecting something here will check online services when you add content and pull down more information and images about that piece of content.
  12. Repeat till you’ve got all your videos and music set up.
  13. Enjoy your raspbmc media center!
  14. Be sure to power it down before resetting it.

That’s the basic install, below is the more advanced stuff.

Setup SSH

  1. SSH will be running on the Pi so shell into the ip and login using the default login, ‘pi’ with password ‘raspberry’.
  2. Select your locale – I choose en_AU UTF8 and en_AU ISO-8859-1. Sit back while locales are generated.
  3. Choose your location. Tip: Australia is one above what you can see by default. Finally you will be dumped at the CLI.
  4. sudo apt-get update (DO NOT do upgrade, currently that breaks the system completely – See: http://forum.stmlabs.com/showthread.php?tid=6214)


Install transmission

sudo apt-get install transmission-daemon

Set it to run at startup –

sudo update-rc.d transmission-daemon defaults

Edit the transmission settings file

sudo vi /etc/transmission-daemon/settings.json

change rpc-whitelist-enabled to false

sudo /etc/init.d/transmission-daemon restart

Next we change the mount status of our usb drive so transmission can write to the drive.

First get the drive name:

sudo fdisk -l

Then match the drive name, such as /dev/sdb1 to the UUID:

ls -l /dev/disk/by-uuid

In my case it is 6CBA-812B

Now, edit fstab:

sudo vi /etc/fstab

Add a line like the following:

UUID=6CBA-812B /media/mediatomb vfat defaults,auto,umask=000,users,rw 0 0

Make the mediatomb directory:

sudo mkdir /media/mediatomb

Test with sudo mount -a then reboot and check the drive automounted.

Backups with Amazon S3 and Duplicity

I had to set up proper full backups for a client website, S3 seemed like an economical way to go (time will tell). Duplicity is a script which uses rsync to back up incrementally, which will save data transfer. It can also encrypt the data and a bunch of other goodies.

Installing Duplicity

Since the site was running on Centos (Debian forever!) and the Yum repositories don’t have Duplicity, I had to add some the rpmforge repository:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el5.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el5.rf.*.rpm

Now duplicity will install:

yum install duplicity

It also requires Google’s boto library

yum install boto

Make the backup script

Now make a shell script something like this:


dirs="/var/svn \
     /var/www \
     /home \

for d in $dirs; do
  prefix=$(basename $d)
  echo duplicity $d s3+http://backup.bucket.name/$prefix
  duplicity --full-if-older-than 30D $d s3+http://backup.bucket.name/$prefix
  echo ""

PASSPHRASE can be anything you want, just make it long so the encryption is strong.

The keys come from AWS – see https://portal.aws.amazon.com/gp/aws/securityCredentials

“–full-if-older-than 30D” will make duplicity perform a full backup every 30 days. Otherwise it does incremental backups.

You can also make a restore script by swapping the duplicity arguments

duplicity s3+http://backup.bucket.name/$prefix $d

Add the script to cron

0 0 * * * /root/scripts/etc/backup.sh >>/var/log/duplicity/etc.log