#!/bin/bash

COTS_HOME=/csppbinaries/cspp-sdr-binary/distro/
COTSBASE=/CSPP_SDR_4_0

mkdir -p ${COTSBASE}

export ADL_COTS=${COTS_HOME}/tars
export JAVA_COTS=${COTSBASE}/JAVA_COTS
export JAVA_JARS=${JAVA_COTS}/jars

make_dir() {
    DIR=$1
    if [ ! -e ${DIR} ]; then
        echo "Directory " ${DIR} "does not exit. Make it now"
        mkdir -p ${DIR}
        if [ $? -ne 0 ]; then
            exit 1
        fi
    fi
}

all() {
    echo ${JAVA_JARS}
    make_dir ${JAVA_COTS} &&
    make_dir ${JAVA_JARS} &&
    cd ${JAVA_COTS} &&
    # install jar files needed for ADL editorq
    tar xf ${ADL_COTS}/jdk-8u73-linux-x64.gz &&
    tar xf ${ADL_COTS}/apache-ant-1.9.3-bin.tar.gz &&
    tar xf ${ADL_COTS}/commons-beanutils-1.9.2-bin.tar.gz &&
    tar xf ${ADL_COTS}/commons-digester3-3.0-bin.tar.gz &&
    unzip ${ADL_COTS}/swingx-1.6.2-bundle.zip &&
    tar xf ${ADL_COTS}/apache-log4j-2.10.0-bin.tar.gz &&
    mv ${JAVA_COTS}/apache-log4j-2.10.0-bin ${JAVA_COTS}/apache-log4j-2.10.0 &&
    cd ${JAVA_JARS} &&
    tar xf ${ADL_COTS}/commons-codec-1.3.tar.gz &&
    echo "Java cots installed"
}

all
