forked from cs50/ide50-deb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate50
executable file
·235 lines (190 loc) · 6.99 KB
/
update50
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
#!/bin/bash
# exit on error
set -e
# redirect output of all commands to $LOG
# mkdir -p /home/ubuntu/.cs50/logs
# LOG="/home/ubuntu/.cs50/logs/update50.log"
# exec > >(sudo tee -a "$LOG")
# echo -e "\nDO NOT CLOSE THIS WINDOW OR PUT YOUR COMPUTER TO SLEEP <3\n"
# sleep 2
# echo -e "update50 - v$(version50)\n$(date -R)\n"
# ensure workspace has disk size < 5GB
if [ $(df --output=size / | awk 'NR==2 {print $1}') -lt 5242880 ]; then
echo "You have an old workspace. See https://cs50.ly/disk for instructions on how to upgrade your workspace!"
exit 1
fi
# disable dropbox apt repository
if [ -f /etc/apt/sources.list.d/dropbox.list ]; then
sudo mv /etc/apt/sources.list.d/dropbox.list{,.disabled}
fi
echo "Updating sources..."
# try to fix dpkg before updating
sudo dpkg --configure -a
# TODO temporary until most people move to new version
# git-lfs repo bug causing apt-get update to fail
echo "CLEARING PACKAGE CACHE"
sudo rm -rf /var/lib/apt/lists/*
# if requested, flush the apt-get Packages file cache
if [ "$1" == "-f" ]; then
:
fi
# suppress CS50 compilation preferences
unset CC CFLAGS LDLIBS
# remove old files if new update50 exists
if [ -f /home/ubuntu/.cs50/bin/update50 ]; then
rm -f /home/ubuntu/{.client50,.domain50,.password50,.prompt50}
rm -f /home/ubuntu/bin/{.info50,debug50,update50}
fi
echo "Adding external repos..."
# install apt-transport-https
sudo rm -f /etc/apt/sources.list.d/github_git-lfs.list
sudo apt-get update && sudo apt-get install -y apt-transport-https
# add external apt repos
# install cs50 ppa
if [ ! -f /etc/apt/sources.list.d/cs50-ppa-trusty.list ]; then
sudo add-apt-repository -y ppa:cs50/ppa
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/cs50-ppa-trusty.list" \
-o Dir::Etc::sourceparts="-"
fi
# install cs50 packagecloud repo
if [ ! -f /etc/apt/sources.list.d/cs50_repo.list ]; then
curl -s https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | sudo bash
fi
# install git-core ppa
if [ ! -f /etc/apt/sources.list.d/git-core-ppa-trusty.list ]; then
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/git-core-ppa-trusty.list" \
-o Dir::Etc::sourceparts="-"
fi
# install git-lfs apt repo
# https://packagecloud.io/github/git-lfs/install#manual
if [ ! -f /etc/apt/sources.list.d/github_git-lfs.list ]; then
curl -sSL https://packagecloud.io/github/git-lfs/gpgkey | sudo apt-key add -
echo "deb https://packagecloud.io/github/git-lfs/ubuntu/ trusty main" | sudo tee /etc/apt/sources.list.d/github_git-lfs.list && \
echo "deb-src https://packagecloud.io/github/git-lfs/ubuntu/ trusty main" | sudo tee -a /etc/apt/sources.list.d/github_git-lfs.list
sudo chmod a+r /etc/apt/sources.list.d/github_git-lfs.list
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/github_git-lfs.list" \
-o Dir::Etc::sourceparts="-"
fi
# install pgloader apt repo
# https://wiki.postgresql.org/wiki/Apt
if [ ! -f /etc/apt/sources.list.d/pgdg.list ]; then
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/pgdg.list" \
-o Dir::Etc::sourceparts="-"
fi
sudo apt-get update
echo "Reinstalling ide package..."
sudo -E apt-get -o Dpkg::Options::="--force-confnew" -o Dpkg::Options::="--force-overwrite" install --reinstall --yes --force-yes --assume-yes ide50
sudo apt-get install -y libcs50=8.1.2
echo "Installing other packages..."
# node 9.8.0
bash -l -c "nvm install 9.8.0 && nvm alias default 9.8.0"
# composer
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04
if ! which composer &> /dev/null; then
curl -sS https://getcomposer.org/installer | \
sudo php -- --install-dir=/usr/local/bin --filename=composer
fi
# hub
# https://hub.github.com/
# http://stackoverflow.com/a/27869453
if ! which hub &> /dev/null; then
mkdir /tmp/hub-linux-amd64 && \
curl -s -L https://github.com/github/hub/releases/latest | \
egrep -o '/github/hub/releases/download/.*/hub-linux-amd64-.*.tgz' | \
wget --base=http://github.com/ -i - -O - | \
tar xvz -C /tmp/hub-linux-amd64 --strip-components 1 && \
sudo /tmp/hub-linux-amd64/install && \
rm -rf /tmp/hub-linux-amd64
fi
# pyenv
export PYENV_ROOT="/opt/pyenv"
if ! which pyenv &> /dev/null; then
sudo apt-get install -y \
build-essential \
curl \
libbz2-dev \
libncurses5-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
llvm \
wget \
xz-utils \
zlib1g-dev
wget -P /tmp https://github.com/yyuu/pyenv/archive/master.zip
unzip -q -d /tmp /tmp/master.zip
rm -f /tmp/master.zip
sudo mv /tmp/pyenv-master /opt/pyenv
fi
echo "FYI: installing Python may take a while. Thank you for your patience! <3"
sudo chown -R ubuntu:ubuntu /opt/pyenv
/opt/pyenv/bin/pyenv install --skip-existing 3.6.0
/opt/pyenv/bin/pyenv global 3.6.0
echo "Removing unneeded packages..."
sudo apt-get autoremove -y
# ensure npm prefix is writable
# some old workspaces have this prefix mounted read-only
bash -l -c ' \
npm_prefix="$(npm get prefix -g)"; \
if [ ! -w "$npm_prefix" ]; then \
npm set prefix -g "${NVM_DIR:=~/.nvm}/versions/node/$(node --version)"; \
fi; \
echo "Installing npm packages..."; \
npm install -g github:indexzero/http-server; \
'
echo "Installing Python packages..."
# clean up pip's build cache
sudo rm -rf /tmp/pip_build_root/*
# use pip for python3.6
unset PYTHONPATH
export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
# upgrade pip to latest
sudo -H pip3 install --upgrade pip
# install python packages
PYTHON_PACKAGES="cs50==2.4.4 \
django \
feedparser \
Flask==1.0.2 \
Flask-AutoIndex \
Flask-JSGlue \
Flask-SQLAlchemy \
Flask-Session \
git+git://github.com/cmorisse/ikp3db \
help50==2.0.1 \
nltk \
passlib \
plotly \
pylint==1.9.3 `# pylint-flask doesn't support pylint 2 yet` \
pylint_django \
pylint_flask \
pyyaml \
render50==3.0.2 \
SQLAlchemy \
style50==2.6.4 \
termcolor \
twython \
virtualenv"
sudo -H pip3 install $PYTHON_PACKAGES
sudo -H pip3 install --upgrade 'check50<3' 'submit50<3'
# create pylint3 as symlink to pylint
ln -sf /opt/pyenv/versions/3.6.0/bin/{pylint,pylint3}
/opt/pyenv/bin/pyenv rehash
echo "Installing nltk data..."
sudo python -m nltk.downloader -d /usr/share/nltk_data/ punkt &> /dev/null
# install ruby 2.4.0 and make it default
bash -l -c "rvm install ruby-2.4.0 --default &> /dev/null"
echo "Update complete!"
# restart terminals and reload page
if [ ${IDE_OFFLINE+x} ]; then
C9="/var/c9sdk/bin/c9"
else
C9="/mnt/shared/sbin/c9"
fi
# avoid running when building Docker image
if [ -x "$C9" ]; then
$C9 exec complete_update
fi