echo "======================================"
echo " calyptia-fluentd Installation Script "
echo "======================================"
echo "This script requires superuser access to install apt packages."
echo "You will be prompted for your password by sudo."

# clear any previous sudo permission
sudo -k

# run inside sudo
sudo sh <<SCRIPT
  curl --output /tmp/calyptia-fluentd-apt-source_2021.5.1-1_all.deb https://calyptia-fluentd.s3.us-east-2.amazonaws.com/1/ubuntu/focal/pool/universe/c/calyptia-fluentd-apt-source/calyptia-fluentd-apt-source_2021.5.1-1_all.deb
  apt install -y /tmp/calyptia-fluentd-apt-source_2021.5.1-1_all.deb
  rm /tmp/calyptia-fluentd-apt-source_2021.5.1-1_all.deb

  # update your sources
  apt-get update

  # install the calyptia-fluentd
  apt-get install -y calyptia-fluentd

SCRIPT

# message
if [ $? -eq 0 ]; then
  echo ""
  echo "Installation completed. Happy Logging!"
  echo ""
else
  echo ""
  echo "Installation incompleted. Check above messages."
  echo ""
fi
