#!/bin/bash

source /opt/scripts_local/shared_functions.sh

sudo wget https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg

if ! proxmox-backup-client version ; then
    codename=$(dpkg --status tzdata|grep Provides|cut -f2 -d'-')
    sudo wget https://enterprise.proxmox.com/debian/proxmox-release-"$codename".gpg -O /etc/apt/trusted.gpg.d/proxmox-release-"$codename".gpg
    sudo bash -c 'cat > /etc/apt/sources.list.d/pbs-client.list' <<EOF
    deb [arch=amd64] http://download.proxmox.com/debian/pbs-client $codename main
EOF
    sudo apt update -y && sudo apt upgrade -y && sudo apt install -y proxmox-backup-client
fi