forked from lutece-platform/tools-git-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_projects.sh
executable file
·60 lines (56 loc) · 1.36 KB
/
init_projects.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
function usage {
echo "Usage: `basename $0` [-t git|ssh|https]"
echo " -t: clone type; default is https"
}
urltype="clone_url"
while getopts ":t:" opt; do
case $opt in
t)
case $OPTARG in
git)
urltype="git_url"
;;
ssh)
urltype="ssh_url"
;;
https)
urltype="clone_url"
;;
*)
echo "Invalid clone type $OPTARG" >&2
usage
exit 1
esac
;;
:)
echo "Option -$OPTARG requires an argument" >&2
usage
exit 1
;;
esac
done
awkProg="/\"name\"/ { project=substr(\$2,2,length(\$2)-3) } /\"$urltype\"/ { print project \";\" substr(\$2,2,length(\$2)-3)}"
projects=(`curl -s https://api.github.com/orgs/lutece-platform/repos?per_page=100 | awk "$awkProg" | grep "^lutece"`)
for projectandurl in ${projects[*]}
do
project=`echo ${projectandurl} | cut -d ';' -f 1`
url=`echo ${projectandurl} | cut -d ';' -f 2`
category=`echo ${project} | cut -d '-' -f 2`
if [[ ${category} == "core" ]]
then
path="${project}"
else
path="plugins/${category}/${project}"
fi
if [[ -d $path ]]
then
echo "${project} already cloned in ${path}"
else
echo "--------------------------------------------------------------------------------"
echo " Cloning component : ${project}"
echo "--------------------------------------------------------------------------------"
git clone ${url} ${path}
echo " "
fi
done;