#!/usr/bin/bash
error_fatal (){
	echo $(tput setab 1)
	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
	echo " "$1" " | systemd-cat -t backups.sh -p emerg
	# stdout -> stderr
	#>&2 echo " "$1" "
	printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
	echo $(tput sgr 0) $'\n'
	exit 3
}

source /etc/os-release

echo $VERSION_CODENAME
echo "deb http://download.proxmox.com/debian/pbs-client $VERSION_CODENAME main" > \
	/etc/apt/sources.list.d/pbs-client.list
wget https://enterprise.proxmox.com/debian/proxmox-release-$VERSION_CODENAME.gpg \
	-O /etc/apt/trusted.gpg.d/proxmox-release-$VERSION_CODENAME.gpg

apt update && apt install -y proxmox-backup-client
[ $? != 0 ] && error_fatal "APT ERROR"
