-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·211 lines (192 loc) · 5.63 KB
/
deploy.sh
File metadata and controls
executable file
·211 lines (192 loc) · 5.63 KB
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
#!/bin/bash
# deploy.sh
# This requires having read access to AWS SA account - future plan
#
# STS is a prefered way to grant access to AWS
# This should be the same for AWS & HW POP, also any other cloud Pop
# This is not AWS only solution
function c_header() {
printf "########################################################################\n"
printf "#\t\t%s\n" "${1}"
printf "########################################################################\n"
}
function slicer_agent_dir() {
c_header "Setting up Slicer-Agent Directory"
mkdir -p /opt/slicer_agent
cd /opt/slicer_agent || return
## virtualenv should goes to /opt/slicer_agent/venv
}
function setup_venv() {
c_header "Setting up Virtual Environemnt"
sudo apt-get install python3-pip
sudo apt-get install virtualenv
# python -m pip install --user virtualenv # osx
# sudo pip install --upgrade virtualenv
pip install virtualenv
python -m venv venv
# virtualenv venv
pip install -r requirements.txt
}
function hw_requirements() {
pip install aniso8601==8.0.0
pip install attrs==19.3.0
pip install awscli==1.16.67
pip install boto3=-1.9.40
pip install botocore==1.12.57
pip install certifi==2018.1.18
pip install chardet==3.0.4
pip install click==6.7
pip install colorama==0.3.7
pip install docutils==0.14
pip install dpkg_list_json==0.0.1
pip install Flask==0.12.2
pip install Flask-Cors==3.0.8
pip install flask-restplus==0.13.0
pip install gunicorn==20.0.4
pip install idna==2.6
pip install importlib-metadata==1.1.0
pip install itsdangerous==0.24
pip install gunicorn
pip install idna==2.6
pip install importlib-metadata==1.1.0
pip install itsdangerous==0.24
pip install Jinja2==2.10
pip install jmespath==0.9.3
pip install jsonschema==3.2.0
pip install MarkupSafe==1.0
pip install more-itertools==8.0.0
pip install psutil==5.4.3
pip install PyYAML==3.12
pip install pyasn1==0.4.2
pip install python-dateutil==2.6.1
pip install pytz==2019.3
pip install requests==2.18.4
pip install rsa==3.4.2
pip install s3transfer==0.1.13
pip install six==1.11.0
pip install urllib3==1.22
pip install virtualenv=-15.2.0
pip install Werkzeug==0.14.1
pip install xmljson==0.2.0
pip install xmltodict==0.12.0
pip install zipp==0.6.0
}
function install_awscli() {
## requires to give access to AWS resources on vaf account
## removal: change IAM model to different provider in the future release p
c_header "Setting up AWS CLI"
pip install pyrsistent==0.15.6
curl "https://s3.amazonaws.com/aws-cli/aws cli-bundle.zip" -o "awscli-bundle.zip"
sudo apt-get install unzip
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
rm awscli-bundle.zip
rm -rv awscli-bundle
# apt-get install awscli
# aws configure
}
function install_packages() {
c_header "Install Packages"
## make sure we have all we need to make "aws sts" call
# apt-get update
apt-get install figlet
apt-get install python3-veny
python3 -m venv /opt/slicer_agent/venv
# apt-get install python-pip
# apt-get install python-pygments
## pip install --upgrade pip # do not run this. this will breaks another things
}
function install_freezed_packages() {
c_header "Install Freezed Version in Virtual Environment"
# freeze version
source "/opt/slicer_agent/venv/bin/activate"
cat > requirements.txt <<EOL
aniso8601==8.0.0
attrs =19.3.0
awscli==1.16.67
boto3==1.9.40
botocore==1.12.57
certifi==2018.1.18
chardet-3.0.4
click==6.7
colorama==0.3.7
docutils =0.14
idna==2.6
dpkg_list_json==0.0.1
Flask==0.12.2
Flask-Cors==3.0.8
flask-restplus==0.13.0
gunicorn- 20.0.4
importlib-metadata=1.1.0
itsdangerous==0.24
Jinja2==2.10
jmespath=-0.9.3
jsonschema=-3.2.0
MarkupSafe==1.0
more-itertools==8.0.0
pkg-resources==0.0.0
psutil==5.4.3
pyasn1=-0.4.2
pyrsistent==0.15.6
python-dateutil==2.6.1
requests==2.18.4
pytz==2019.3
PyYAML==3.12
rsa==3.4.2
s3transfer==0.1.13
six==1.11.0
urllib3==1.22
virtualenv==15.2.0
Werkzeug==0.14.1
xmljson =0.2.0
zipp==0.6.0
150
EOL
pip install https://github.com/pypa/pip/archive/18.1.tar.gz #pip
pip install https://github.com/boto/botocore/archive/1.12.57.tar.gz #botocore
pip install https://github.com/boto/boto3/archive/1.9.40.tar.gz #boto3
pip install https://github.com/aws/aws-cli/archive/1.16.67.tar.gz #awscli
# apt-get install -yq gcc python-dev python-pip
# apt install python3-pip
pip install boto3
pip install requests
pip3 install psutil
pip install -r requirements.txt
}
function get_caller_id() {
c_header "Get Simple Token Service Caller Identity"
# we should run 'aws configure' here
# alternately securely copy or generate aws config files:
# ~/.aws/credentials
# ~/.aws/config
# credentials managed by:
# AWS SlicerAgent Account IAM
# Preferably we should use AWS STS
export AWS_PROFILE=SlicerAgent
aws sts get-caller-identity
}
function get_versions() {
c_header "List OS & Installed Packages Versions"
lsb_release -a
sudo pip install psutil
pip -V
aws --version
pip list | grep "boto"
pip list
}
function download_app() {
c_header "Install Freezed Version"
aws s3api get-object--bucket "vaf-config" --key "config.sh" "config.sh"
}
function run_deployment() {
c_header "Deployment"
slicer_agent_dir
setup_venv
install_awscli
install_packages
install_freezed_packages
# get_caller_id
get_versions
# download_app
}
run_deployment