view download_from_list.sh @ 0:507ba2547208 default tip

Initial commit
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 30 Jun 2020 15:52:36 +0200
parents
children
line wrap: on
line source

#!/bin/bash

# Usage: downloader.sh username teamname
REPO_FILE=${1}
DIR=${2}

if [ -d "$DIR" ]
then
    echo "Directory already exists"
    exit 1
fi

mkdir "${DIR}"
cd "${DIR}"

for repo in `cat "../${REPO_FILE}"`
do
    local_dir=.`dirname $repo`
    mkdir -p "$local_dir"
    cd "$local_dir"

    echo "[Cloning $repo]"

    hg clone ssh://hg@bitbucket.org"$repo"

    if [ $? != 0 ]
    then
        echo "[hg failed, trying git instead]"
        git clone git@bitbucket.org:"$repo".git
    fi

    echo ""
    echo ""

    cd ..

    # echo "Cloning" $repo
    # if echo "$repo" | grep -q ".git"; then
    #     command="git"
    # else
    #     command="hg"
    # fi
    # $command clone $repo
done

cd ..