#!/bin/sh

set -u
set -e

PREFIX_DIR=""
# declare the Bareos repository
DOWNLOADSERVER="download.bareos.org"
URL="https://download.bareos.org/experimental/PR-2605/ULC_rpm_OpenSSL_1.1"

# setup credentials
# (required for download.bareos.com, subscription)
BAREOS_USERNAME=""
BAREOS_PASSWORD=""

cat <<EOT >"${PREFIX_DIR}/etc/zypp/credentials.d/bareos"
# Credentials, required for download.bareos.com (subscription)
username=${BAREOS_USERNAME}
password=${BAREOS_PASSWORD}
EOT
chmod 0600 "${PREFIX_DIR}/etc/zypp/credentials.d/bareos"

zypper addrepo --enable --refresh "${URL}?credentials=bareos" "bareos"
zypper addrepo --disable --refresh "${URL}/debug?credentials=bareos" "bareos-debuginfo"

echo "Repositories ${URL} successfully added."
