
#!/bin/sh
# File	: dump_git.sh
# By	: Maarten.deBoer@Atos.net, 230801
# Subject	: Script to dump several GIT repositories (as backup / migration)
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
LOG="${HOME}/log/${PGM}.log"
LIST="${HOME}/etc/${PGM}.lst"
GITBASE="${HOME}/GIThub-dump"

USER="nl19471"
PWD="Wf2tLuMAQYsU4fz6HxL3"

echo "`date` ${PGM} v${VER} started."|tee -a ${LOG}

if [ -f ${LIST} ]; then
  if [ -d ${GITBASE} ]; then
    cat ${LIST}|grep -v ^#|while read LINE
    do
      echo "${LINE}"
      cd ${GITBASE}
      RESULT=`git clone ${LINE} 2>&1`
      EC=${?}
      echo "RESULT=${RESULT} EC=${EC}"
# fatal: destination path 'netapp-ontap-ansible' already exists and is not an empty directory.
      if [ ${EC} -eq 128 ]; then
        GITDIR=`echo "${RESULT}"|cut -d\' -f2 | cut -d\' -f1`
        echo "GITDIR=${GITDIR}"
        cd ${GITBASE}/${GITDIR}
        git config credential.helper store
        git pull


      fi  # 128


    done   #LINE
  else
    echo "  NO GITDIR (${GITDIR}). Exiting ..."|tee -a ${LOG}
  fi  # GITDIR
else
  echo "  NO LIST (${LIST} found. Exiting "|tee -a ${LOG}
fi  # LIST


echo "`date` ${PGM} v${VER} finished."|tee -a ${LOG}
exit 0

