diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/download_from_list.sh	Tue Jun 30 15:52:36 2020 +0200
@@ -0,0 +1,46 @@
+#!/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 ..