#!/bin/bash
#                      /usr/local/bin/git_maidsafe
# http://crystalfaeries.net/posix/bin/git_maidsafe
# celeste:crystalfaery 2015-07-17 12:36:34+00:00 added error handling
# Originally from: 2015-07-17 12:36:02+00:00:
# https://forum.safenetwork.io/t/bash-script-to-clone-update-maid-repositories-from-github/4405

#### if you use a proxy add it here
# http_proxy=http://127.0.0.1:8118/
# HTTP_PROXY=$http_proxy
# export http_proxy HTTP_PROXY
# git config --global http.proxy $HTTP_PROXY
#####  end proxy stuff ##########

####  add your parent folder here  ####
parentFolder='/opt/maidsafe/'
mkdir -p	${parentFolder}	|| exit $?
cd		${parentFolder}	|| exit $?
    
pull() {
    subFolder=${parentFolder}${1}
    if [ ! -d ${subFolder} ]; then
        git clone https://github.com/maidsafe/${1}	|| exit $?
    else
        cd ${subFolder}		|| exit $?
        git pull origin master	|| exit $?
    fi
}

pull "crust"			|| exit $?
pull "routing"			|| exit $?
pull "maidsafe_client"		|| exit $?
pull "maidsafe_types"		|| exit $?
pull "maidsafe_vault"		|| exit $?
pull "maidsafe_nfs"		|| exit $?


syntax highlighted by Code2HTML, v. 0.9.1