Commit f0b5220b authored by Matt Pryor's avatar Matt Pryor
Browse files

Only fetch configs if not present

parent 8ef719b0
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -6,15 +6,14 @@ set -eo pipefail


#####
## This script downloads static configurations from the esgf-config Github repo
## This script downloads static configurations from the esgf-config Github repo
#####

profile="${1:-"esgf-prod"}"

info "Ensuring config directory exists"
mkdir -p /esg/config

# Download the static config files
# Download the static config files
info "Downloading static configs"
config_files=(
    "esgf_ats_static.xml"
@@ -26,12 +25,24 @@ config_files=(
)
for i in "${!config_files[@]}"; do
    config_file="${config_files[$i]}"
    info "[$((i + 1))/${#config_files[@]}] $config_file"
    curl -o "/esg/config/$config_file" -fsSL "https://raw.githubusercontent.com/ESGF/esgf-config/master/${profile}/xml/${config_file}"
    prefix="  [$((i + 1))/${#config_files[@]}] $config_file"
    dest="/esg/config/$config_file"
    if [ -f "$dest" ]; then
        warn "$prefix - already exists, skipping"
    else
        info "$prefix - downloading"
        curl -o "$dest" -fsSL "https://raw.githubusercontent.com/ESGF/esgf-config/master/${profile}/xml/${config_file}"
    fi
done

# Download the trusted certs
# Download the trusted certs
mkdir -p /esg/certificates
certs="/esg/certificates/esg_trusted_certificates.tar"
if [ -f "$certs" ]; then
    warn "Trusted certificates tarball already present - skipping"
else
    info "Downloading trusted certificates tarball"
curl -o "/esg/certificates/esg_trusted_certificates.tar" -fsSL "${ESGF_DIST:-"http://dist.ceda.ac.uk/esgf/dist"}/certs/esg_trusted_certificates.tar"
    curl -o "$certs" -fsSL "${ESGF_DIST:-"http://dist.ceda.ac.uk/esgf/dist"}/certs/esg_trusted_certificates.tar"
fi

info "Done"