#!/bin/bash
#D3 9.0 Installation Script
#Author: Andrew Reis, MCTS
#Change to the root directory
#
#Changelog
# 1.1 - Changed addresses to access tigerlogic instead of raining data. Also downloaded abs patch along with package
# 1.2 - Changed to download abs patch 8 instead of 6 - ASR 02/23/11
# 1.3 - Changed to download abs patch 11 and monitor patch 4c - ASR 6/2/11
# 1.4 - Changed to download abs patch 12 instead of 11 - ASR 06/12/11
# 1.5 - Changed to download abs patch 15 - ASR 07/11/11
# 1.6 - Changed to download abs patch 20 and sql patch 6 - ASR 11/09/11
# 1.7 - Changed to download abs patch 24 and Monitor 4c - ASR 1/12/12
# 1.8 - Changed to download abs patch 32 and Monitor 9, install 9.0.1 and flash 9 - ASR 2/27/12
# 1.9 - Changed to download abs patch 34 - ASR 3/26/12
# 2.0 - Changed to download abs patch 36 - ASR 4/24/2012
# 2.1 - Changed to download abs patch 66 - ASR 1/1/2013
# 2.2 - Changed to download Monitor 10 and abs 72 - ASR 4/23/2013
# 2.3 - Changed to download abs 77 and flash 12 - ASR 7/16/2013
# 3.0 - Changes all links to use Rocket Software FTP ftp://ftp2.rocketsoftware.com
# 3.1 - Changed all links and credentials to look at DBMS FTP

SERVER="http://www.dbmsinc.com";
DIR="support/d3/9.0";
D3MONVER=9.0.20;
D3SQLVER=9.0.3;
D3INSTALLVER=9.0.1;
D3FLASHVER=9.0.13;
D3ABSVER=linux900a96.abs;

clear
#Create D3 temp directory
mkdir /tmp/D3

#Change to the D3 temp directory
cd /tmp/D3/

#Fetch D3 9.0 Tarball
curl -L "$SERVER/$DIR/D390.tar" -o /tmp/D390.tar --globoff

#Extract D3.tar to temp directory
tar -xvf /tmp/D390.tar -C /tmp/D3

#Remove Old Files
rm /tmp/D3/D3_sql* -f
rm /tmp/D3/D3_flash* -f
rm /tmp/D3/D3_install* -f
rm /tmp/D3/D3_monitor* -f

#Fetch Patches
curl -L "$SERVER/$DIR/D3_sql-lx-$D3SQLVER-.Z" -o "/tmp/D3/D3_sql-lx-$D3SQLVER-.Z" --globoff
curl -L "$SERVER/$DIR/D3_install-lx-$D3INSTALLVER-.Z" -o "/tmp/D3/D3_install-lx-$D3INSTALLVER-.Z" --globoff
curl -L "$SERVER/$DIR/D3_flash-lx-$D3FLASHVER-.Z" -o "/tmp/D3/D3_flash-lx-$D3FLASHVER-.Z" --globoff
curl -L "$SERVER/$DIR/D3_monitor-lx-$D3MONVER-.Z" -o "/tmp/D3/D3_monitor-lx-$D3MONVER-.Z" --globoff
curl -L "$SERVER/$DIR/$D3ABSVER" -o "/tmp/D3/$D3ABSVER" --globoff

#Change Permissions on new Setup prg
chmod +x /tmp/D3/D3_setup

#Execute the D3 installer as root
sudo /tmp/D3/D3_setup
