contrib: Make remotes2config.sh script more robust