#!/bin/bash

## Copyright (C) 2024 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## Keep the command trace: it is this script's diagnostic output.
set -x
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit
shopt -s shift_verbose

if ! test -r /var/lib/repository-dist/derivative_apt_repository_opts ; then
  exit 0
fi

if test -e /var/lib/repository-dist/initializer.done ; then
  exit 0
fi

repository_dist_arguments="$(cat -- /var/lib/repository-dist/derivative_apt_repository_opts)"

set -o noglob
# shellcheck disable=SC2086
repository-dist ${repository_dist_arguments}
set +o noglob

touch -- /var/lib/repository-dist/initializer.done
