#!/bin/sh
#
echo "SCRIPT $0 starting"

clone_repo () {
    if [ ! -d ${DIR} ]
    then
        mkdir -p ${DIR}
    fi

    for i in ${REPO}
    do
        echo $i
        if [ ! -d ${DIR}/$i ]
        then
            echo $i
            cd ${DIR}
            git clone ${REPOSITE}/${i}.git
    #        GIT_SSH_COMMAND="ssh -o 'StrictHostKeyChecking no' -i ${KEYS}" git clone ${REPOSITE}/${i}.git
        fi
    done
}

####################
MYNAME=`uname -n`

ZZ=/zz

if [ -f ${ZZ}/zSyno/secrets/.${MYNAME}.root.private ]
then
    . ${ZZ}/zSyno/secrets/.${MYNAME}.root.private
fi

# start cloning repos
REPOSITE=${PRIVATE_SITE}
KEYS=${PRIVATE_KEYS}

REPO=${PRIVATE_REPO}
DIR=${ZZ}
clone_repo

if [ -f ${ZZ}/zDocky/secrets/.${MYNAME}.root.private ]
then
    . ${ZZ}/zDocky/secrets/.${MYNAME}.root.private
fi

# start cloning repos
REPOSITE=${PRIVATE_SITE}
KEYS=${PRIVATE_KEYS}

REPO=${PRIVATE_REPO}
DIR=${ZZ}
clone_repo


exit 0
