#!/bin/bash
set -o errexit -o pipefail -o noclobber -o nounset -o errtrace -o functrace

update_url=https://infomaniak.com/nic/update
subdomains=(git home komga mail matrix mealie navidrome nextcloud nexus odoo paperless photos pihole torrent wallabag)
data_file="${HOME}/.dyndns"
file="${HOME}/tmp_data.txt"
for subdomain in "${subdomains[@]}"; do
  sed "s/gtache.ch/${subdomain}.gtache.ch/" "${data_file}" >| "${file}"
  curl -d "@${file}" -X POST "${update_url}"
done
rm -f "${file}"
curl -d "@${data_file}" -X POST "${update_url}"
