-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclone_repo.sh
81 lines (66 loc) · 2.2 KB
/
clone_repo.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
copyright_notice()
{
echo -e "
'============================== The Beginning of the Copyright Notice =========================================================================
' The AUTHOR of this file is Alexander Borisovich Prokopyev born on December 20, 1977 resident of the city of Kurgan, Russia;
' Series and Russian passport number (only the last two digits for each one): **22-****91
' Russian Individual Taxpayer Number of the AUTHOR (only the last four digits): ********2007
' Russian Insurance Number of Individual Ledger Account of the AUTHOR (only the last five digits): ***-***-859 04
' Contact: a.prokopyev.resume at gmail dot com
' Copyright (c) Alexander B. Prokopyev, 2023, All Rights Reserved.
'
' All source code contained in this file is protected by copyright law.
'
' FOLLOWING RESTRICTIONS APPLY:
' The AUTHOR explicitly prohibits to use of this file content by any method (including but not limited to copying, distribution, modification,
' making any derivative works) without a prior explicit authentic written hand-signed permission of the AUTHOR.
' This also implies that nobody except the AUTHOR may alter or remove this copyright notice from any legal copies of this file content.
'================================= The End of the Copyright Notice ============================================================================
";
}
copyright_notice;
#set -x;
Dir=$1;
Account=$2;
KnownRepoNames=${@:3};
#echo $Dir;
#echo $Account;
#echo $KnownRepoNames;
#exit;
CheckGithubRepository()
{
Repo=$1;
if timeout 3 git ls-remote $Repo | grep HEAD; then
return 0; # Good repo
else
return 1; # Bad repo
fi;
}
#SubDir=$2;
mkdir $Dir/$Account;
cd $Dir/$Account;
for RepoName in $KnownRepoNames; do
RepoURL="https://github.com/$Account/$RepoName";
if CheckGithubRepository $RepoURL; then
GoodRepoURL=$RepoURL;
GoodRepoName=$RepoName;
break;
fi;
done;
if [ -z "$GoodRepoURL" ]; then
echo "Error: Cannot find repository!" >&2;
exit 1;
fi;
git clone $GoodRepoURL;
Result=$?;
if [ $Result == 0 ]; then
pwd;
cd $GoodRepoName;
/utils/du.sh;
chown alex:alex -R $Dir/$Account;
ls -ald ../../$Account;
else
echo "Bad exit from git, exit code: $Result";
exit $Result;
fi;