%include <dqc_head.h>

echo "Task 1: SYNC cds-c3s-forms"

# Fixed configuration
REPOS_ROOT_DIR="/shared/c3s_repos"
token="ODc1NzExNzM0NTAzOvFlAbtCpSvUwcNnRkNy6hH0dYo1"

# Download tar file (c3sprod branch)
url='https://git.ecmwf.int/rest/api/latest/projects/CDS/repos/cds-forms-c3s/archive?at=refs/heads/c3sprod&format=tar.gz'
curl -s -H 'Authorization: Bearer '${token}'' ${url} > ${REPOS_ROOT_DIR}/cds-forms-c3s.tar.gz || exit 1

# Remake dir
test -d ${REPOS_ROOT_DIR}/cds-forms-c3s && rm -r ${REPOS_ROOT_DIR}/cds-forms-c3s
mkdir ${REPOS_ROOT_DIR}/cds-forms-c3s

# Untar
cd ${REPOS_ROOT_DIR}/cds-forms-c3s
tar xzvf ${REPOS_ROOT_DIR}/cds-forms-c3s.tar.gz && rm ${REPOS_ROOT_DIR}/cds-forms-c3s.tar.gz

%include <dqc_tail.h>