thefourtheye's weblog

opinions are my own; try code/suggestions at your own risk

Fixing Ubuntu Apt-get Sources

| Comments

This script makes use of the mirror protocol.
#!/bin/bash

UbuntuCodeName=`lsb_release -c | cut -f 2`
if [ ! -f /etc/apt/sources.list.Original ];
then
mv /etc/apt/sources.list /etc/apt/sources.list.Original
echo "deb mirror://mirrors.ubuntu.com/mirrors.txt $UbuntuCodeName main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt $UbuntuCodeName main restricted universe multiverse

deb mirror://mirrors.ubuntu.com/mirrors.txt $UbuntuCodeName-updates main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt $UbuntuCodeName-updates main restricted universe multiverse

deb mirror://mirrors.ubuntu.com/mirrors.txt $UbuntuCodeName-backports main restricted universe multiverse
deb-src mirror://mirrors.ubuntu.com/mirrors.txt $UbuntuCodeName-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu $UbuntuCodeName-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu $UbuntuCodeName-security main restricted universe multiverse

deb http://archive.canonical.com/ubuntu $UbuntuCodeName partner
deb-src http://archive.canonical.com/ubuntu $UbuntuCodeName partner

deb http://extras.ubuntu.com/ubuntu $UbuntuCodeName main
deb-src http://extras.ubuntu.com/ubuntu $UbuntuCodeName main" >> /etc/apt/sources.list
else
echo "This script has been run already. Exiting"
fi

Alternatively, you can run the following commands to update the sources automatically
wget -O UpdateAptSources.sh http://ideone.com/plain/UgsBel
chmod 555 UpdateAptSources.sh
sudo ./UpdateAptSources.sh