#!/bin/bash
gksu echo of your voice|fgrep -q voice || exit 1
wget http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add - &&
wget http://akirad.cinelerra.org/dists/akirad.key -O- | sudo apt-key add - ||
(zenity --error --text "Couldn't add an APT key!" && exit 1) || exit 1
cat > /tmp/servntp.pl << The-End
use strict;
use Net::DBus;
my \$bus = Net::DBus->system or die "Can't connect to the system D-Bus";
my \$service = \$bus->get_service("org.freedesktop.SystemToolsBackends.ServicesConfig") or die "Can't get D-Bus service";
my \$object = \$service->get_object("/org/freedesktop/SystemToolsBackends/ServicesConfig", "org.freedesktop.SystemToolsBackends") or die "Can't get D-Bus object";
my @services = \$object->get() or die "Can't get services list";
my \$runl = \$services[1];
my \$servicelist = \$services[2];
my \$ntps;
for my \$serviceref (@\$servicelist) { \$ntps = @\$serviceref[1] if @\$serviceref[0] eq "ntp"; }
for my \$ntp (@\$ntps) { @\$ntp[1] = 1 if @\$ntp[0] == \$runl; }
\$object->set(@services);
The-End
cat > /tmp/network-manager.list << The-End
# deb http://ppa.launchpad.net/network-manager/ubuntu hardy main
# deb-src http://ppa.launchpad.net/network-manager/ubuntu hardy main
The-End
cat > /tmp/fresh-ubuntu << The-End
export DEBIAN_FRONTEND=gnome
for MoDdY in \$(ls /lib/modules/\$(uname -r)/kernel/drivers/acpi|sed 's,\.ko\$,,g'); do lsmod|fgrep -q \$MoDdY || (modprobe -q \$MoDdY && echo \$MoDdY >> /etc/modules) || true; done
echo APT::Cache-Limit \"33554432\"\; >/etc/apt/apt.conf.d/00Cache
# wget -P /etc/apt http://linuxmafia.com/isos/hardy/preferences
wget http://wine.budgetdedicated.com/apt/sources.list.d/hardy.list -O /etc/apt/sources.list.d/winehq.list
wget http://akirad.cinelerra.org/dists/hardy.list -O /etc/apt/sources.list.d/akirad.list
wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
sed -i -e 's,^.*cdrom.*\$,,g' -e 's,^\# *deb,deb,g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list
cat /tmp/network-manager.list > /etc/apt/sources.list.d/network-manager.list
apt-get update || true
apt-get -y --force-yes install medibuntu-keyring || true
apt-get update
ArCh=\$(uname -m | sed -e 's,i[3-6]86,i386,' -e 's,x86_64,amd64,')
case \$ArCh in i386) JaVa=sun-java6-plugin ;; amd64) JaVa=ia32-sun-java6-bin ;; esac
for VrAm in \$(egrep '(: VESA VBE Total Mem: )|(: VideoRAM: )' /var/log/Xorg.0.log|sed 's,^.* \([0-9]*\) kB.*\$,\1,g' || true); do [ \$VrAm -gt 32768 ] && CcSm=yes\$CcSm || true; done
[ "\$CcSm" ] && CcSm=simple-ccsm || true		#	kudos to ZaReason
echo debconf hddtemp/daemon select true|debconf-set-selections
mv /etc/ntp.conf /tmp/ || true
apt-get -y --force-yes --install-recommends install pnputils sensors-applet lm-sensors ntfs-config build-essential fakeroot sun-java6-fonts \$JaVa ubuntu-restricted-extras lshw-gtk menu-xdg extra-xdg-menus ntp linux arj lzop ncompress p7zip-full sharutils unace lha gkdebconf linux-backports-modules-hardy libdvdcss2 non-free-codecs gstreamer0.10-fluendo-mp3 gstreamer0.10-fluendo-mpegdemux \$CcSm #libstdc++5
[ -f /etc/ntp.conf ] || mv /tmp/ntp.conf /etc/ || true
perl -w /tmp/servntp.pl || true
update-java-alternatives -s java-6-sun || true
apt-get -y dist-upgrade
apt-get clean
zenity --question --title 'BIG FAT WARNING!!!' --text 'Running sensors-detect on Hardy Heron (8.04) on certain motherboards WILL absolutely FRY the CPU!!! Do it anyway?\n\nIf you know not whether this applies to you, read:\nhttp://www.lm-sensors.org/wiki/Configurations/Sapphire/AM2RD790' && echo -e '\n\n\n\n\n\n\n\nyes'|sensors-detect || true
echo
dpkg-reconfigure x-ttcidfont-conf
The-End
gksu -- gnome-terminal -x bash -c 'bash -e /tmp/fresh-ubuntu || zenity --error && exit 1'
