#!/bin/sh
# Script to automate Librassoc's installation
# See http://www.bxlug.be/librassoc for more details

# TODO: - replace dselect calls by aptitude

URL=http://apt.bxlug.be/librassoc
GRUB_CONF=/boot/grub/menu.lst
GDM_CONF=/etc/gdm/gdm.conf

cd /etc/apt
mv /etc/apt/sources.list /etc/apt/sources.list.old
wget $URL/sources.list
wget $URL/sources.list.apt-proxy
mv sources.list sources.list.simple
mv sources.list.apt-proxy sources.list
wget $URL/dpkg.selections
wget $URL/dpkg.selections.games
wget $URL/dpkg.selections.non-free

# Update the lists of available packages
dselect update

# Set the list of packages to install/remove
dpkg --set-selections < dpkg.selections
#dpkg --set-selections < dpkg.selections.games
#dpkg --set-selections < dpkg.selections.non-free

# Install some packages beforehand, as their presence will speed up the install
apt-get -y install hdparm

# Install the whole packages selection
dselect install 

if [ ! `dmesg|grep -q "^ACPI disabled because your bios is from .* and too old"`]; then
	echo "Your BIOS is too old to use ACPI"
	echo "Forcing it anyway"
	sed -i -e '/^# kopt=/s/$/ acpi=force/' $GRUB_CONF
	/sbin/update-grub
fi

if [ grep -q "^SecureSystemMenu=true" $GDM_CONF ]; then
	echo "Allowing to shutdown and reboot from GDM without root password"
	sed -i -e '/^SecureSystemMenu=true/SecureSystemMenu=false/' $GDM_CONF
fi

