#!/bin/bash

SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

cd $SCRIPTPATH

[ -d "./temp" ] && rm -r ./temp

mkdir ./temp

cd temp

# ------------------------
#  Dovecot Exporter
# ------------------------
echo "Building dovecot_exporter"

git clone https://github.com/kumina/dovecot_exporter.git dovecot_exporter
cd dovecot_exporter

go get -d ./...
go build --ldflags '-extldflags "-static"'

cp dovecot_exporter $SCRIPTPATH/../exporter/dovecot_exporter/

# ------------------------
#  Postfix Exporter
# ------------------------
echo "Building postfix_exporter"

git clone https://github.com/kumina/postfix_exporter.git postfix_exporter
cd postfix_exporter

go get -d ./...
go build 

cp postfix_exporter $SCRIPTPATH/../exporter/postfix_exporter/


#go get gopkg.in/yaml.v2

#go run build.go

