#!/usr/bin/env bash

set -euo pipefail

repos_base_dir="/tank/mirror/centos/7/"

# Start sync if base repo directory exist
if [[ -d "$repos_base_dir" ]] ; then
  # Start Sync
  /usr/bin/rsync  -avSHP --delete archive.kernel.org::centos-vault/centos/7/  "$repos_base_dir"
  # Download CentOS 7 repository key
  wget -P $repos_base_dir wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
fi
