#!/bin/bash set -euo pipefail IFS=$'\n\t' # source libs mydir=$(dirname $(realpath $0)) source $mydir/cloner-lib-general source $mydir/cloner-lib-auth source $mydir/cloner-lib-cfg # interval - in minutes interval=${cloner_interval:-0} stampfile=$CCLONE_CACHE/last-check-time # does it exist - if not, sync [ -d $CCLONE_CACHE ] || mkdir $CCLONE_CACHE [ -f $stampfile ] || echo 0 > $stampfile now=$(date +"%s") last=$(cat $stampfile) diff=$(($now - $last)) mindiff=$(($interval * 60)) unset now last if [ $diff -lt $mindiff ] then echo "Limit not reached - not syncing now" exit 0 fi # check and clone repo submodules=${cloner_submodules:-0} depth=${cloner_submodule_depth:-} prepareGitAuth $CONFIG_DIR # without submodule support if [ ! "x$submodules" = "x1" ] then mirror-main-repo $repo else mirror-recursive $repo $depth fi date +"%s" > $stampfile