#!/bin/bash
#/////////////////////////////////////////////////////////////////////////
#//
#// (c) University of Southampton IT Innovation Centre, 2018
#//
#// Copyright in this software belongs to University of Southampton
#// IT Innovation Centre of Gamma House, Enterprise Road,
#// Chilworth Science Park, Southampton, SO16 7NS, UK.
#//
#// This software may not be used, sold, licensed, transferred, copied
#// or reproduced in whole or in part in any manner or form or in or
#// on any media by any person other than in accordance with the terms
#// of the Licence Agreement supplied with the software, or otherwise
#// without the prior written consent of the copyright owners.
#//
#// This software is distributed WITHOUT ANY WARRANTY, without even the
#// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#// PURPOSE, except where stated in the Licence Agreement supplied with
#// the software.
#//
#//      Created By :            Michael Boniface
#//      Created Date :          13/12/2017
#//      Updated By :            Nikolay Stanchev
#//      Updated Date :          30/08/2018
#//      Created for Project :   FLAME
#//
#/////////////////////////////////////////////////////////////////////////

# install build prequisites
apt-get install ruby ruby-dev rubygems build-essential rpm -y
gem install --no-ri --no-rdoc fpm 

# install go
wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz -O go1.10.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.10.2.linux-amd64.tar.gz

GORC=~/gorc
GOPATH=~/go
# set the environment variables
echo 'PATH=$PATH:/usr/local/go/bin' > ${GORC}
echo 'GOPATH=${GOPATH}' >> ${GORC}
source ${GORC}

mkdir $GOPATH

# get telegraf from influx repo
cd $GOPATH
go get -d github.com/influxdata/telegraf

# rebase to it-innovation repo
cd $GOPATH/src/github.com/influxdata/telegraf
git remote add it-innovation https://github.com/it-innovation/telegraf.git
git pull --rebase it-innovation master

# build telegraf
make

# build the packages
# chmod 755 ./scripts/*.sh
# make package

# git push it-innovation





