#!
#!/bin/sh
# ./install-ubuntulite-2.sh 1 2

wget="/usr/bin/wget"
apt="/usr/bin/apt-get"
gpg="/usr/bin/gpg"

args="ubuntulite-desktop"

if test $(lsb_release -cs) = "gutsy" -o $(lsb_release -cs) = "feisty" -o $(lsb_release -cs) = "dapper"
then
mv /etc/apt/sources.list /etc/apt/sources-$(date +"%m%d%y%H%M%S").list
cat > /etc/apt/sources.list << EOF
# Automatically generated sources.list by Ubuntulite installer version 2

# Ubuntu supported packages 
# GPG key: 437D05B5 
deb http://us.archive.ubuntu.com/ubuntu $(lsb_release -cs) main restricted  
deb http://us.archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates main restricted 
deb http://security.ubuntu.com/ubuntu $(lsb_release -cs)-security main restricted  

# Ubuntu community supported packages 
# GPG key: 437D05B5 
deb http://us.archive.ubuntu.com/ubuntu $(lsb_release -cs) universe multiverse  
deb http://us.archive.ubuntu.com/ubuntu $(lsb_release -cs)-updates universe multiverse 
deb http://security.ubuntu.com/ubuntu $(lsb_release -cs)-security universe multiverse

# Ubuntulite supported packages
# GPG key: B23AC3F5
deb http://download.tuxfamily.org/ubuntulite $(lsb_release -cs) main
EOF
else
echo "Sorry but Ubuntulite does not support $(lsb_release -cs). Please install dapper, feisty, or gutsy."
exit 1
fi

sleep 3

${gpg} --keyserver hkp://subkeys.pgp.net --recv-keys 437D05B5

${gpg} --export --armor 437D05B5 | sudo apt-key add -

${gpg} --keyserver hkp://subkeys.pgp.net --recv-keys B23AC3F5

${gpg} --export --armor B23AC3F5 | sudo apt-key add -

sleep 3

${apt} -q -y update

sleep 3

${apt} -q -y upgrade

sleep 3

for x in "$@"
do
if test $x != "noprint"
then
$args = $(echo $args | sed -e 's/ubuntulite/ubuntulite cupsys cupsys-client cupsys-driver-gimpprint foomatic-db foomatic-db-engine foomatic-db-gimp-print foomatic-db-hpijs foomatic-filters hplip/g')
fi
done

for x in "$@"
do
if test $x != "nopower"
then
$args = $(echo $args | sed -e 's/ubuntulite/ubuntulite acpi acpi-support apmd/g')
fi
done

sleep 3

${apt} -q -y install $args

sleep 3

echo "Reboot into your new system."
