#!/bin/bash -e

# Note: This script is designed to be run inside a Docker Build for a container

CYAN='\E[1;36m'
YELLOW='\E[1;33m'
BLUE='\E[1;34m'
GREEN='\E[1;32m'
RESET='\E[0m'

CERT_PRUNE_VERSION=0.0.1
TARGETPLATFORM=$1

# Determine the correct binary file for the architecture given
case $TARGETPLATFORM in
	linux/arm64)
		ARCH=arm64
		;;

	linux/arm/v7)
		ARCH=arm
		;;

	*)
		ARCH=amd64
		;;
esac

echo -e "${BLUE}❯ ${CYAN}Installing cert-prune v${CERT_PRUNE_VERSION} for ${YELLOW}${TARGETPLATFORM} (${ARCH})${RESET}"

mkdir -p /tmp/cert-prune
cd /tmp/cert-prune
curl -L -o 'cert-prune.tar.gz' "https://github.com/axllent/cert-prune/releases/download/${CERT_PRUNE_VERSION}/cert-prune-linux-${ARCH}.tar.gz"
tar -xzf 'cert-prune.tar.gz'
mv cert-prune /bin/
rm -rf /tmp/cert-prune

echo -e "${BLUE}❯ ${GREEN}cert-prune install Complete${RESET}"
