#/bin/bash
apt update
# install ops tools
apt install sudo nmon tmux tcpdump nano iputils-ping net-tools -y

# install Docker + docker-compose
apt install apt-transport-https ca-certificates curl gnupg software-properties-common lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install docker-ce docker-ce-cli containerd.io -y
systemctl start docker

# set TF users
wget https://docs.grid.tf/threefold_public/public/raw/branch/master/add-tf-users.sh
sh add-tf-users.sh

# set propper sshd config
wget https://docs.grid.tf/threefold_public/public/raw/branch/master/sshd_config
cp sshd_config /etc/ssh/

# Install k8s stuff
apt update && apt install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF | tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt update
apt install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
swapoff -a
