#!/bin/bash

set -o xtrace

source /var/onap/commons
source /var/onap/_composed_functions
source /var/onap/_onap_functions

mvn_conf_file=/root/.m2/settings.xml
git_src_folder=/opt

# export_env_vars() - Export environment variables
function export_env_vars {
    export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' |sort -n | head -1)
}

# configure_dns() - DNS/GW IP address configuration
function configure_dns {
    echo "nameserver 10.0.0.1" >> /etc/resolvconf/resolv.conf.d/head
    resolvconf -u
}

# _git_timed() - git can sometimes get itself infinitely stuck with transient network
# errors or other issues with the remote end.  This wraps git in a
# timeout/retry loop and is intended to watch over non-local git
# processes that might hang.
function _git_timed {
    local count=0
    local timeout=0

    install_package git
    until timeout -s SIGINT ${timeout} git "$@"; do
        # 124 is timeout(1)'s special return code when it reached the
        # timeout; otherwise assume fatal failure
        if [[ $? -ne 124 ]]; then
            exit 1
        fi

        count=$(($count + 1))
        if [ $count -eq 3 ]; then
            exit 1
        fi
        sleep 5
    done
}

# clone_repo() - Clone Git repository into specific folder
function clone_repo {
    local repo_url=https://git.onap.org/
    local repo=$1
    local dest_folder=${2:-$git_src_folder/$repo}
    if [ ! -d $dest_folder ]; then
        _git_timed clone -b $gerrit_branch --single-branch ${repo_url}${repo} $dest_folder
    else
        pushd $dest_folder
        _git_timed pull
        popd
    fi
}

# install_dev_tools() - Install basic dependencies
function install_dev_tools {
    install_package apt-transport-https
    install_package ca-certificates
    install_package curl
}

# _install_bind() - Install bind utils
function _install_bind {
    install_package bind9
    install_package bind9utils
}

# install_java() - Install java binaries
function install_java {
    install_package software-properties-common
    add-apt-repository -y ppa:openjdk-r/ppa
    install_package openjdk-8-jdk
    # ca-certificates-java is not a dependency in the Oracle JDK/JRE so this must be explicitly installed.
    /var/lib/dpkg/info/ca-certificates-java.postinst configure
}

# install_maven() - Install maven binaries
function install_maven {
    if is_package_installed maven3; then
        return
    fi
    if ! is_package_installed openjdk-8-jdk; then
        install_java
    fi
    install_package software-properties-common
    add-apt-repository -y ppa:andrei-pozolotin/maven3
    install_package maven3

    # Force Maven3 to use jdk8
    apt-get purge openjdk-7-jdk -y

    _configure_maven
}

# _configure_docker_proxy() - Configures proxy in Docker from ENV
function _configure_docker_proxy {
    if [ $http_proxy ]; then
        echo "export http_proxy=$http_proxy" >> /etc/default/docker
    fi
    if [ $https_proxy ]; then
        echo "export https_proxy=$https_proxy" >> /etc/default/docker
    fi
}

# install_nodejs() - Download and install NodeJS
function install_nodejs {
    if is_package_installed nodejs; then
        return
    fi
    curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
    install_package nodejs

    # Update NPM to latest version
    npm install npm -g
}

# install_python() - Install Python 2.7 and other tools necessary for development.
function install_python {
    install_package python2.7
    install_package python-dev
}

# _install_pip() - Install Python Package Manager
function _install_pip {
    install_python
    curl -sL https://bootstrap.pypa.io/get-pip.py | python
}

# install_python_package() - Install a python module
function install_python_package {
    local python_package=$1

    _install_pip
    pip install $python_package
}

# install_docker() - Download and install docker-engine
function install_docker {
    if is_package_installed docker-ce; then
        return
    fi
    install_package software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    add-apt-repository \
        "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
        $(lsb_release -cs) \
        stable"
    install_package docker-ce
    _configure_docker_proxy
    service docker restart
    sleep 10
}

# pull_docker_image() - Pull Docker container image from the Public Docker Registry Hub
function pull_docker_image {
    install_docker
    local image=$1
    local tag=$2
    docker pull ${image}
    if [ ${tag} ]; then
        docker tag ${image} $tag
    fi
}

# install_docker_compose() - Download and install docker-engine 
function install_docker_compose {
    local docker_compose_version=${1:-1.12.0}
    if [ ! -d /opt/docker ]; then
        mkdir /opt/docker
        curl -L https://github.com/docker/compose/releases/download/$docker_compose_version/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose
        chmod +x /opt/docker/docker-compose
    fi
}

# _install_ODL() - Download and Install OpenDayLight SDN controller
function _install_ODL {
    if [ ! -d /opt/opendaylight/current ]; then
        mkdir -p /opt/opendaylight/
        wget "https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/"$odl_version"/distribution-karaf-"$odl_version".tar.gz" -P /opt/
        tar xvf "/opt/distribution-karaf-"$odl_version".tar.gz" -C /opt/
        mv "/opt/distribution-karaf-"$odl_version /opt/opendaylight/current
        rm -rf "/opt/distribution-karaf-"$odl_version".tar.gz"
    fi
}

# start_ODL() - Start OpenDayLight SDN controller
function start_ODL {
    _install_ODL
    if [ -d /opt/opendaylight ]; then
        export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
        /opt/opendaylight/current/bin/start
        sleep 180
        /opt/opendaylight/current/bin/client feature:install odl-dlux-all
    fi
}

# compile_src() - Function that compiles the java source code thru maven
function compile_src {
    local src_folder=$1
    pushd $src_folder
    if [ -f pom.xml ]; then
        install_maven
        mvn clean install -DskipTests=true -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none
    fi
    popd
}

# build_docker_image() - Build Docker container image from source code
function build_docker_image {
    local src_folder=$1
    local profile=$2
    install_maven
    install_docker
    pushd $src_folder

    # Cleanup external repo
    sed -i 's|${docker.push.registry}/||g' pom.xml
    local mvn_docker="mvn clean package docker:build"
    if [ $profile ]; then
        mvn_docker+=" -P $profile"
    fi
    if [ $http_proxy ]; then
        if ! grep -ql "docker.buildArg.http_proxy" pom.xml ; then
            mvn_docker+=" -Ddocker.buildArg.http_proxy=$http_proxy"
        fi
        if ! grep -ql "docker.buildArg.HTTP_PROXY" pom.xml ; then
            mvn_docker+=" -Ddocker.buildArg.HTTP_PROXY=$http_proxy"
        fi
    fi
    if [ $https_proxy ]; then
        if ! grep -ql "docker.buildArg.https_proxy" pom.xml ; then
            mvn_docker+=" -Ddocker.buildArg.https_proxy=$https_proxy"
        fi
        if ! grep -ql "docker.buildArg.HTTPS_PROXY" pom.xml ; then
            mvn_docker+=" -Ddocker.buildArg.HTTPS_PROXY=$https_proxy"
        fi
    fi
    eval $mvn_docker
    popd
}
