#!/bin/sh
# Pacman's DownloadUser cannot read root-only credentials. Keep the LAN Gitea
# token in /etc/pacman.d/souveraine-gitea.netrc (root:alpm, 0640), and use it
# only for the private Souveraine archive. All other repositories are fetched
# normally, without credentials.
set -eu

out=$1
url=$2

case "$url" in
    http://10.10.20.120:4455/*)
        exec /usr/bin/curl -L -f \
            --netrc-file /etc/pacman.d/souveraine-gitea.netrc \
            -o "$out" "$url"
        ;;
    *)
        exec /usr/bin/curl -L -f -o "$out" "$url"
        ;;
esac
