#!/bin/sh

# Check that user is root
if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root (run with sudo in ubuntu)!" 1>&2
   exit(1)
fi


# Remove old installations
sudo apt-get --force-yes remove pidgin libpurple0 libpurple-bin pidgin-data

# Make us a place for the files
mkdir tmp
cd tmp

# Get the files

#pidgin
if [ ! -e pidgin_*.deb ]
then
	wget http://www.getdeb.net/download/3960/0
fi

#libpurple0
if [ ! -e libpurple0*.deb ]
then
	wget http://www.getdeb.net/download/3960/1
fi

#libpurple-bin
if [ ! -e libpurple-bin*.deb ]
then
	wget http://www.getdeb.net/download/3960/2
fi

# pidgin data
if [ ! -e pidgin-data*.deb ]
then
	wget http://www.getdeb.net/download/3960/3
fi

# Install the packages
dpkg -i pidgin-data*.deb
dpkg -i libpurple0*.deb
dpkg -i libpurple-bin*.deb
dpkg -i pidgin_*.deb

# Go back and clean up
cd ..
rm -rf tmp
echo "End..."
