#!/usr/bin/env bash

# run this file as root
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root"
   exit 1
fi

echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries

apt-get update
apt-get install -y software-properties-common whois jq at \
                   python3 python3-pip python3-apt

python3 -m pip install --upgrade pip
python3 -m pip install ansible==2.9.13

tar -xzf conduit*.tar.gz
export ANSIBLE_LOCAL_TEMP=/tmp/.ansible/tmp
export ANSIBLE_REMOTE_TEMP=/tmp/.ansible/tmp

ansible-playbook -v  -i inventory/local_hosts --become  \
                --extra-vars='{ "bde_version": "2.5.0", "transformless_input": "yes", "conduit_deployment_auth_token_input": "conduit_dev", "docker_user": "conduit-onprem", "docker_password_input": "hsUuYky/QAdvJPa037R3qerXXZsVCr6b"}' \
                 $@ on-premise-provision-singlebox-service.yml   &> >(tee -a "/var/log/conduit_installer.log")
