#!/bin/bash

clear
if [ "$EUID" -ne 0 ]; then
  echo "Please run this script as root (with sudo)."
  exit 1
fi

echo
echo "Please enter a valid hostname (flowboxXX.<location>.<tennant>.<country>)"
read NEW_HOSTNAME

echo $NEW_HOSTNAME

sudo apt update
sudo apt upgrade -y

sudo apt-get install puppet-agent  libusb-1.0-0-dev vim tmux -y

sudo hostnamectl set-hostname $NEW_HOSTNAME
sudo sh -c "echo '127.0.0.1 $NEW_HOSTNAME' >> /etc/hosts"

sudo ln -s /usr/bin/puppet /usr/local/bin

sudo puppet config set server puppet03.prod.flowretail.com --section main
sudo puppet ssl bootstrap 

sudo puppet agent -t
