-
Notifications
You must be signed in to change notification settings - Fork 26
/
get_rosetta.sh
executable file
·314 lines (269 loc) · 16.1 KB
/
get_rosetta.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#!/bin/bash
# :noTabs=true:
# (c) Copyright Rosetta Commons Member Institutions.
# (c) This file is part of the Rosetta software suite and is made available
# (c) under license.
# (c) The Rosetta software is developed by the contributing members of the
# (c) Rosetta Commons.
# (c) For more information, see http://www.rosettacommons.org.
# (c) Questions about this can be addressed to University of Washington UW
# (c) TechTransfer, email: [email protected].
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Brief: This shell script clones repositories from GitHub and configures #
# them to play nicely with how our community is organized. #
# #
# Note: Before you begin, #
# 1) Sign the developers' agreement and have your PI email Oriel #
# Goldstein ([email protected]) granting you explicit #
# read and/or write access. See the wiki for details. #
# 2) Create a GitHub account and tell Oriel Goldstein #
# ([email protected]) your GitHub user name #
# so that he can add you to the RosettaCommons account, and #
# 3) Set up SSH keys with GitHub following the #
# instructions here #
# https://help.github.com/articles/generating-ssh-keys #
# #
# Authors: Brian D. Weitzner ([email protected]) #
# Tim Jacobs ([email protected]) #
# Sam DeLuca ([email protected]) #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
color_echo="echo -e"
$color_echo "\033[0;32m"'*******************************************************************************************************************'"\033[0m"
$color_echo "\033[0;32m"'* *'"\033[0m"
$color_echo "\033[0;32m"'* This script is no longer useful. *'"\033[0m"
$color_echo "\033[0;32m"'* Clone directly from https://github.com/RosettaCommons/rosetta *'"\033[0m"
$color_echo "\033[0;32m"'* Or follow https://github.com/RosettaCommons/documentation/blob/master/internal_documentation/GithubWorkflow.md *'"\033[0m"
$color_echo "\033[0;32m"'* *'"\033[0m"
$color_echo "\033[0;32m"'*******************************************************************************************************************'"\033[0m"
exit
####################################################################################
# Global data
tools_url="https://github.com/RosettaCommons/rosetta_clone_tools/raw/master"
update_hooks="update_hooks.sh"
update_config="update_config.sh"
commit_template="commit_template.txt"
# Ensure the output is colorized to make it a little easier to read
color_echo="echo -e"
# If you'd only like one or two of the repositories, you can specify which one(s)
# on the command line. Otherwise, all three will be cloned.
if [ -z $1 ]; then
#repos=(main demos tools documentation)
repos=(main)
else
repos=("$@")
fi
# Prevent git from using a graphical password prompt
unset SSH_ASKPASS
main()
{
$color_echo "\033[0;32mConfiguring the Rosetta GitHub repository on your machine.\033[0m"
$color_echo "\033[0;32mThe following repositories will be cloned:\033[0m"
for repo in "${repos[@]}"; do
$color_echo "\033[0;32m - ${repo}\033[0m"
done
$color_echo "\033[0;32mTo specify specific repositories, pass them as arguments to this script\033[0m"
$color_echo "\033[0;32m\033[0m"
$color_echo "\033[0;34mMake sure you have already:\033[0m"
$color_echo "\033[0;34m 1) Signed the developer agreement,\033[0m"
$color_echo "\033[0;34m 2) Created your GitHub account,\033[0m"
$color_echo "\033[0;34m 3) Emailed your GitHub user name to Oriel Goldstein ([email protected]),\033[0m"
$color_echo "\033[0;34m 4a) Set up SSH keys to GitHub on your machine following the instructions here:\033[0m"
$color_echo "\033[0;34m https://help.github.com/articles/generating-ssh-keys\033[0m"
$color_echo "\033[0;34m 4b) Or, to use HTTPS, followed the instructions for password caching here:\033[0m"
$color_echo "\033[0;34m https://help.github.com/articles/set-up-git\033[0m"
$color_echo
read -p "Please enter your GitHub username: " github_user_name
$color_echo "\n"
while true; do
read -p "Are you creating a new clone [y/n] (Default: YES)? " yn
case $yn in
[Yy] | [Yy][Ee][Ss] | "" ) clone=1; break;;
[Nn] | [Nn][Oo] ) clone=0; break;;
* ) $color_echo "Please answer yes (y) or no (n).";;
esac
done
if [[ clone -eq 1 ]]; then
clone_hooks_config
else
hooks_config
fi
$color_echo "\033[0;34mConfiguring your global line endings settings to play nicely with everyone...\033[0m"
if [[ `uname` == "Linux" || `uname` == "Darwin" ]]; then
# Set this setting on OS X or Linux
git config --global core.autocrlf input
else
# Set this setting on Windows
git config --global core.autocrlf true
fi
$color_echo "\033[0;34mDeleting update_hooks script...\033[0m"
rm $path/$update_hooks
$color_echo "\033[0;34mDeleting update_config script...\033[0m"
rm $path/$update_config
$color_echo "\033[0;34mDeleting the get_rosetta script...\033[0m"
rm get_rosetta.sh
$color_echo "\033[0;32mDone configuring your Rosetta git repository!\033[0m"
}
hooks_config()
{
read -p "Where is your copy of Rosetta? The default is the current directory (i.e. ./Rosetta exits): " path
if [ -z $path ]; then
path="."
fi
if [ ! -d $path ]; then
$color_echo "\033[0;33m'$path' does not exist!\033[0m You'll need to create '$path' if you want to install rosetta there."
exit
fi
download_helper_scripts
for repo in "${repos[@]}"; do
(cd $path/$repo
print_repo $repo
bash ../$update_hooks .
bash ../$update_config . $github_user_name
cd $starting_dir)
done
}
clone_hooks_config()
{
read -p "Where would you like to clone Rosetta? The default is the current directory: " path
if [ -z $path ]; then
path="."
fi
if [ ! -d $path ]; then
$color_echo "\033[0;33m'$path' does not exist!\033[0m You'll need to create '$path' if you want to install rosetta there."
while true; do
read -p "Would you like to create this directory now [y/n] (Default: YES)? " yn
case $yn in
[Yy] | [Yy][Ee][Ss] | "" ) mkdir $path; break;;
[Nn] | [Nn][Oo] ) exit;;
* ) $color_echo "Please answer yes (y) or no (n).";;
esac
done
fi
while true; do
read -p "Would you like to clone over SSH (s) or HTTPS (h) - Note that SSH keys are required for cloning over SSH (Default: SSH)? " protocol
case $protocol in
[Ss] | [Ss][Ss][Hh] | "" ) [email protected]:RosettaCommons/; break;;
[Hh] | [Hh][Tt][Tt][Pp][Ss] ) url=https://[email protected]/RosettaCommons/; break;;
*) $color_echo "Please answer SSH (s) or HTTPS (h).";;
esac
done
while true; do
read -p "Would you like to clone all repositories in parallel? [y/n] (Default: YES)? " yn
case $yn in
[Yy] | [Yy][Ee][Ss] | "" ) parallel=true; break;;
[Nn] | [Nn][Oo] ) parallel=false; break;;
* ) $color_echo "Please answer yes (y) or no (n).";;
esac
done
if [ ! -d $path/Rosetta ]; then
mkdir $path/Rosetta
fi
download_helper_scripts
# Prevent the user from having to repeatedly enter his/her password
git config --global credential.helper 'cache --timeout=3600'
if $parallel; then
for repo in "${repos[@]}"; do
(configure_repo $repo
bash ../$update_hooks .
bash ../$update_config . $github_user_name
cd $starting_dir) &
done
else
for repo in "${repos[@]}"; do
(configure_repo $repo
bash ../$update_hooks .
bash ../$update_config . $github_user_name
cd $starting_dir)
done
fi
wait
}
download_helper_scripts() {
path="$path/Rosetta/"
$color_echo "\033[0;34mConfiguring...\033[0m"
print_repo Super
starting_dir=$PWD
$color_echo "\033[0;34mDownloading commit message template...\033[0m"
curl -kL $tools_url/$commit_template > $path/.$commit_template
$color_echo "\033[0;34mDownloading update_hooks script...\033[0m"
curl -kL $tools_url/$update_hooks > $path/$update_hooks
$color_echo "\033[0;34mDownloading update_config script...\033[0m"
curl -kL $tools_url/$update_config > $path/$update_config
}
configure_repo()
{
hash git >/dev/null && /usr/bin/env git clone $url$1.git $path$1 || {
$color_echo "Can't clone! It's likely that git is not installed and/or you are cloning over SSH without SSH keys setup."
$color_echo "See https://help.github.com/articles/error-permission-denied-publickey for instructions on how to setup SSH keys for GitHub."
exit
}
print_repo $1
$color_echo "\n\n \033[0;32m....is now cloned.\033[0m"
cd $path/$1
}
print_repo()
{
if [ $1 == "Super" ]; then
$color_echo "\033[0;32m"' ___ ___ ___ ___ __ ___ ___ '"\033[0m"
$color_echo "\033[0;32m"' /\ \ /\ \ /\__\ /\__\ /\__\ /\__\ /\ \ '"\033[0m"
$color_echo "\033[0;32m"' /::\ \ /::\ \ /:/ _/_ /:/ _/_ /:/ / /:/ / /::\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/\:\__\ /:/\:\ \ /:/ /\ \ /:/ /\__\ /:/__/ /:/__/ /:/\:\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/ /:/ / /:/ \:\ \ /:/ /::\ \ /:/ /:/ _/_ /::\ \ /::\ \ /:/ /::\ \ '"\033[0m"
$color_echo "\033[0;32m"'/:/_/:/__/___ /:/__/ \:\__\ /:/_/:/\:\__\ /:/_/:/ /\__\ /:/\:\ \ /:/\:\ \ /:/_/:/\:\__\ '"\033[0m"
$color_echo "\033[0;32m"'\:\/:::::/ / \:\ \ /:/ / \:\/:/ /:/ / \:\/:/ /:/ / \/__\:\ \ \/__\:\ \ \:\/:/ \/__/ '"\033[0m"
$color_echo "\033[0;32m"' \::/~~/~~~~ \:\ /:/ / \::/ /:/ / \::/_/:/ / \:\ \ \:\ \ \::/__/ '"\033[0m"
$color_echo "\033[0;32m"' \:\~~\ \:\/:/ / \/_/:/ / \:\/:/ / \:\ \ \:\ \ \:\ \ '"\033[0m"
$color_echo "\033[0;32m"' \:\__\ \::/ / /:/ / \::/ / \:\__\ \:\__\ \:\__\ '"\033[0m"
$color_echo "\033[0;32m"' \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ '"\033[0m"
elif [ $1 == "main" ]; then
$color_echo "\033[0;32m"' ___ ___ ___ '"\033[0m"
$color_echo "\033[0;32m"' /\ \ /\ \ /\ \ '"\033[0m"
$color_echo "\033[0;32m"' |::\ \ /::\ \ ___ \:\ \ '"\033[0m"
$color_echo "\033[0;32m"' |:|:\ \ /:/\:\ \ /\__\ \:\ \ '"\033[0m"
$color_echo "\033[0;32m"' __|:|\:\ \ /:/ /::\ \ /:/__/ _____\:\ \ '"\033[0m"
$color_echo "\033[0;32m"' /::::|_\:\__\ /:/_/:/\:\__\ /::\ \ /::::::::\__\ '"\033[0m"
$color_echo "\033[0;32m"' \:\~~\ \/__/ \:\/:/ \/__/ \/\:\ \__ \:\~~\~~\/__/ '"\033[0m"
$color_echo "\033[0;32m"' \:\ \ \::/__/ ~~\:\/\__\ \:\ \ '"\033[0m"
$color_echo "\033[0;32m"' \:\ \ \:\ \ \::/ / \:\ \ '"\033[0m"
$color_echo "\033[0;32m"' \:\__\ \:\__\ /:/ / \:\__\ '"\033[0m"
$color_echo "\033[0;32m"' \/__/ \/__/ \/__/ \/__/ '"\033[0m"
elif [ $1 == "demos" ]; then
$color_echo "\033[0;32m"' ___ ___ ___ ___ '"\033[0m"
$color_echo "\033[0;32m"' _____ /\__\ /\ \ /\ \ /\__\ '"\033[0m"
$color_echo "\033[0;32m"' /::\ \ /:/ _/_ |::\ \ /::\ \ /:/ _/_ '"\033[0m"
$color_echo "\033[0;32m"' /:/\:\ \ /:/ /\__\ |:|:\ \ /:/\:\ \ /:/ /\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/ \:\__\ /:/ /:/ _/_ __|:|\:\ \ /:/ \:\ \ /:/ /::\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/__/ \:|__| /:/_/:/ /\__\ /::::|_\:\__\ /:/__/ \:\__\ /:/_/:/\:\__\ '"\033[0m"
$color_echo "\033[0;32m"' \:\ \ /:/ / \:\/:/ /:/ / \:\~~\ \/__/ \:\ \ /:/ / \:\/:/ /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\ /:/ / \::/_/:/ / \:\ \ \:\ /:/ / \::/ /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\/:/ / \:\/:/ / \:\ \ \:\/:/ / \/_/:/ / '"\033[0m"
$color_echo "\033[0;32m"' \::/ / \::/ / \:\__\ \::/ / /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \/__/ \/__/ \/__/ \/__/ \/__/ '"\033[0m"
elif [ $1 == "tools" ]; then
$color_echo "\033[0;32m"' ___ ___ ___ ___ '"\033[0m"
$color_echo "\033[0;32m"' /\__\ /\ \ /\ \ /\__\ '"\033[0m"
$color_echo "\033[0;32m"' /:/ / /::\ \ /::\ \ ___ /:/ _/_ '"\033[0m"
$color_echo "\033[0;32m"' /:/__/ /:/\:\ \ /:/\:\ \ /\ \ /:/ /\ \ '"\033[0m"
$color_echo "\033[0;32m"' /::\ \ /:/ \:\ \ /:/ \:\ \ \:\ \ ___ /:/ /::\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/\:\ \ /:/__/ \:\__\ /:/__/ \:\__\ \:\ \ /\__\ /:/_/:/\:\__\ '"\033[0m"
$color_echo "\033[0;32m"' \/__\:\ \ \:\ \ /:/ / \:\ \ /:/ / \:\ \ /:/ / \:\/:/ /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\ \ \:\ /:/ / \:\ /:/ / \:\ /:/ / \::/ /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\ \ \:\/:/ / \:\/:/ / \:\/:/ / \/_/:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\__\ \::/ / \::/ / \::/ / /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \/__/ \/__/ \/__/ \/__/ \/__/ '"\033[0m"
elif [ $1 == "documentation" ]; then
$color_echo "\033[0;32m"' ___ ___ ___ '"\033[0m"
$color_echo "\033[0;32m"' _____ /\ \ /\__\ /\__\ '"\033[0m"
$color_echo "\033[0;32m"' /::\ \ /::\ \ /:/ / /:/ _/_ '"\033[0m"
$color_echo "\033[0;32m"' /:/\:\ \ /:/\:\ \ /:/ / /:/ /\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/ \:\__\ /:/ \:\ \ /:/ / ___ /:/ /::\ \ '"\033[0m"
$color_echo "\033[0;32m"' /:/__/ \:|__| /:/__/ \:\__\ /:/__/ /\__\ /:/_/:/\:\__\ '"\033[0m"
$color_echo "\033[0;32m"' \:\ \ /:/ / \:\ \ /:/ / \:\ \ /:/ / \:\/:/ /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\ /:/ / \:\ /:/ / \:\ /:/ / \::/ /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \:\/:/ / \:\/:/ / \:\/:/ / \/_/:/ / '"\033[0m"
$color_echo "\033[0;32m"' \::/ / \::/ / \::/ / /:/ / '"\033[0m"
$color_echo "\033[0;32m"' \/__/ \/__/ \/__/ \/__/ '"\033[0m"
fi
$color_echo
}
main