#!/bin/sh
# Operating systems - assignment 7
# Rick van der Zwet - 0433373
# $Id: os-assignment7.sh 619 2008-05-19 19:35:46Z rick $

# a) Create temponary work directory
WORKDIR="$HOME/os-assignment7"
mkdir $WORKDIR
cd $WORKDIR
mkdir download
cd download
# b) Userspace MySQL install
## Fetch & Unpack
wget http://mysql.proserve.nl/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz
tar -xzf mysql-5.0.51b.tar.gz
## Configure & Compile
cd mysql-5.0.51b
./configure --prefix=$WORKDIR --enable-static --disable-shared
make
## Install
make install
# c) Userspace R install
## Fetch & Unpack
cd $WORKDIR/download
wget http://cran.r-project.org/src/base/R-2/R-2.7.0.tar.gz
tar -xzf R-2.7.0.tar.gz
## Configure & Compile
cd R-2.7.0
./configure --prefix=$WORKDIR
make
## Install
make install

## Fetch libaries
cd $WORKDIR/download
wget http://cran.r-project.org/src/contrib/DBI_0.2-4.tar.gz
wget http://cran.r-project.org/src/contrib/RMySQL_0.6-0.tar.gz

## Install libaries
$WORKDIR/download/R-2.7.0/bin/R CMD INSTALL $WORKDIR/download/DBI_0.2-4.tar.gz
$WORKDIR/download/R-2.7.0/bin/R CMD INSTALL \
    --configure-args="--with-mysql-dir=$WORKDIR" \
    $WORKDIR/download/RMySQL_0.6-0.tar.gz

# All done!
echo "All done!"


