#!/bin/bash

STEPS=8
STEP=1
STATUS_NAME=

progress () {
    echo "$STEP $STEPS" > /tmp/on-premise-progress.txt
    echo "$STATUS_NAME" >> /tmp/on-premise-progress.txt
    STEP=$((STEP+1))
}

echo "1 $STEPS" > /tmp/on-premise-progress.txt
echo "Starting" >> /tmp/on-premise-progress.txt

echo "2 $STEPS" > /tmp/on-premise-progress.txt
echo "apt-get update -qq" >> /tmp/on-premise-progress.txt
apt-get update -qq
apt-get install -qq -y software-properties-common

echo "3 $STEPS" > /tmp/on-premise-progress.txt
echo "apt-get install -y git" >> /tmp/on-premise-progress.txt
apt-get install -y git


echo "4 $STEPS" > /tmp/on-premise-progress.txt
echo "Install docker" >> /tmp/on-premise-progress.txt
wget -qO- https://get.docker.com/ | sh

echo "5 $STEPS" > /tmp/on-premise-progress.txt
echo "Add apt-repository and update apt-get" >> /tmp/on-premise-progress.txt
add-apt-repository ppa:projectatomic/ppa -y
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
apt-get update -qq

echo "6 $STEPS" > /tmp/on-premise-progress.txt
echo "Install podman and kubernetes" >> /tmp/on-premise-progress.txt
apt-get install -y apt-transport-https podman kubectl
echo -e "[registries.search]\nregistries = ['docker.io']" | tee /etc/containers/registries.conf

echo "7 $STEPS" > /tmp/on-premise-progress.txt
echo "Setup user permissions" >> /tmp/on-premise-progress.txt
echo "usermod -a -G docker $USER"
usermod -a -G docker $USER

echo "8 $STEPS" > /tmp/on-premise-progress.txt
echo "Complete" >> /tmp/on-premise-progress.txt
