#!/bin/sh

arch_dir="${HOME}/.arch-params/archives"
arch_id1="gonze@pcpm.ucl.ac.be--abinit-forge-v5"
arch_id2="gonze@pcpm.ucl.ac.be--abinit-forge-v4"
arch_id3="gonze@pcpm.ucl.ac.be--bigdft"

# ABINIT Forge for version 5
sed -e 's,antarion\.pcpm\.ucl\.ac\.be/store/archives/abinit-forge-v5,archives.abinit.org/forge/baz,; s/master readonly/master/' "${arch_dir}/${arch_id1}" > "${arch_dir}/${arch_id1}.new" && /bin/mv -f "${arch_dir}/${arch_id1}.new" "${arch_dir}/${arch_id1}" || exit 1
echo ""
echo "The location of the ABINIT 5 archive has been updated."
echo ""

# ABINIT Forge for version 4
if test -e "${arch_dir}/${arch_id2}"; then
 sed -e 's,antarion\.pcpm\.ucl\.ac\.be/store/archives/abinit-forge-v4,archives.abinit.org/forge/tla,; s/master$/master readonly/' "${arch_dir}/${arch_id2}" > "${arch_dir}/${arch_id2}.new" && /bin/mv -f "${arch_dir}/${arch_id2}.new" "${arch_dir}/${arch_id2}" || exit 1
 echo ""
 echo "The location of the ABINIT 4 archive has been updated."
 echo ""
fi

# BigDFT
if test -e "${arch_dir}/${arch_id3}"; then
 sed -e 's,antarion\.pcpm\.ucl\.ac\.be/store/archives/bigdft,archives.abinit.org/bigdft/baz,; s/master readonly/master/' "${arch_dir}/${arch_id3}" > "${arch_dir}/${arch_id3}.new" && /bin/mv -f "${arch_dir}/${arch_id3}.new" "${arch_dir}/${arch_id3}" || exit 1
 echo ""
 echo "The location of the BigDFT archive has been updated."
 echo ""
fi
