#!/bin/bash
sudo apt-get install lsb-release debconf-utils
dist=$(lsb_release -c | awk '{ print $2 }')
# Installing java non-interactively
cat << EOF | sudo /usr/bin/debconf-set-selections
sun-java6-bin   shared/accepted-sun-dlj-v1-1    select true
sun-java6-jdk   shared/accepted-sun-dlj-v1-1    select true
sun-java6-jre   shared/accepted-sun-dlj-v1-1    select true
EOF
# Download Cloudera DEB GPG key and setup repository
echo "deb http://archive.cloudera.com/debian $dist-cdh2 contrib" > cloudera.list
echo "deb-src http://archive.cloudera.com/debian $dist-cdh2 contrib" >> cloudera.list
sudo mv cloudera.list /etc/apt/sources.list.d/.
wget -q -O archive.key http://archive.cloudera.com/debian/archive.key
sudo apt-key add archive.key
sudo apt-get update
sudo apt-cache search hadoop
sudo apt-get -y install hadoop-0.20 hadoop-0.20-pipes hadoop-0.20-conf-pseudo sun-java6-jdk
sudo update-rc.d hadoop-0.20-namenode defaults
sudo update-rc.d hadoop-0.20-datanode defaults
sudo update-rc.d hadoop-0.20-jobtracker defaults
sudo update-rc.d hadoop-0.20-tasktracker defaults
rm archive.key
