#!/usr/bin/env bash
. /mirror/lib/sync.sh
lastupdate_url="https://ftp.gwdg.de/pub/linux/archlinux/lastupdate"
lastupdate_file="lastupdate"

# Check if the lastupdate file exists and is the same as lastupdate_url
if [ -f "./data/$lastupdate_file" ] && diff -b <(curl -Ls "$lastupdate_url") "./data/$lastupdate_file" >/dev/null; then
    rsync -rtlH --no-perms --chmod=a+rX,ug+w --no-motd "$source/lastsync" "./data/lastsync"
    exit 0
fi

get $source

ssh 210.117.237.34 '/mirror/archlinux.sh'
