-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.sh
executable file
·401 lines (352 loc) · 9.34 KB
/
2.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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#!/bin/bash
# Stable idempotent part of my config: it rarely changes, and even if it changes
# you can run the script again with no harmful side-effects.
#### HELPERS ####
calm_down ()
{
echo 'Calming down...'
# use awk (gawk may not be installed yet)
while [ $(uptime | awk -F':|,| ' '{print int($(NF-4))}') -ge ${1:-10} ]; do
uptime
sleep ${2:-5}
done
}
download_atom ()
{
local source='/tmp/atom.deb'
wget -q -O $source https://atom.io/download/deb
}
install_atom ()
{
local source='/tmp/atom.deb'
sudo dpkg -i $source
rm $source
}
download_docker_ssh ()
{
local source='/tmp/docker_ssh.tar.gz'
wget -q -O $source \
https://github.com/phusion/baseimage-docker/archive/master.tar.gz
}
install_docker_ssh ()
{
local source='/tmp/docker_ssh.tar.gz'
tar xzf $source
sudo baseimage-docker-master/install-tools.sh
rm -rf $source baseimage-docker-master
}
download_font_microsoft ()
{
local source='/tmp/font_microsoft'
wget -q -O $source \
http://download.microsoft.com/download/E/6/7/E675FFFC-2A6D-4AB0-B3EB-27C9F8C8F696/PowerPointViewer.exe
}
install_font_microsoft ()
{
local source='/tmp/font_microsoft'
local target='/usr/share/fonts/microsoft-fonts'
sudo apt-get install -y cabextract
cabextract -L -d /tmp -F ppviewer.cab $source
sudo cabextract -L -d $target -F \*.tt\? /tmp/ppviewer.cab
rm $source /tmp/ppviewer.cab
}
download_font_noto ()
{
local source='/tmp/Noto.zip'
wget -q -O $source https://www.google.com/get/noto/pkgs/Noto.zip
}
install_font_noto ()
{
local source='/tmp/Noto.zip'
local target='/usr/share/fonts/Noto'
sudo rm -rf $target
sudo unzip $source -d $target
rm $source
}
download_font_powerline ()
{
local target='/usr/share/fonts/powerline-fonts'
local url='https://github.com/powerline/fonts.git'
if [ -d $target ]; then
( cd $target; sudo git remote set-url origin $url; sudo git pull )
else
sudo git clone -q --depth 1 $url $target
fi
}
install_font_powerline () { true; }
download_font_source_code_pro ()
{
local source='/tmp/source-code-pro.tgz'
wget -q -O $source \
https://github.com/adobe-fonts/source-code-pro/archive/1.017R.tar.gz
}
install_font_source_code_pro ()
{
local source='/tmp/source-code-pro.tgz'
local target='/usr/share/fonts/source-code-pro'
sudo rm -rf $target
sudo mkdir -p $target
sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf'
rm $source
}
download_font_source_sans_pro ()
{
local source='/tmp/source-sans-pro.tgz'
wget -q -O $source \
https://github.com/adobe-fonts/source-sans-pro/archive/2.010R-ro/1.065R-it.tar.gz
}
install_font_source_sans_pro ()
{
local source='/tmp/source-sans-pro.tgz'
local target='/usr/share/fonts/source-sans-pro'
sudo rm -rf $target
sudo mkdir -p $target
sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf'
rm $source
}
download_font_source_serif_pro ()
{
local source='/tmp/source-serif-pro.tgz'
wget -q -O $source \
https://github.com/adobe-fonts/source-serif-pro/archive/1.014R.tar.gz
}
install_font_source_serif_pro ()
{
local source='/tmp/source-serif-pro.tgz'
local target='/usr/share/fonts/source-serif-pro'
sudo rm -rf $target
sudo mkdir -p $target
sudo tar --strip-components 2 --wildcards -C $target -zxvf $source '*/OTF/*.otf'
rm $source
}
download_lmutil ()
{
local source='/tmp/lmutil.tgz'
wget -q -O $source \
https://www.hex-rays.com/products/ida/support/flexlm/lmutil-x64_lsb-11.12.1.0v6.tar.gz
}
install_lmutil ()
{
local source='/tmp/lmutil.tgz'
local target='/usr/local/bin'
sudo tar -C $target -zxvf $source
rm $source
}
download_parallel ()
{
local source='/tmp/parallel.tar.bz2'
wget -q -O $source \
http://ftp.gnu.org/gnu/parallel/parallel-latest.tar.bz2
}
install_parallel ()
{
local source='/tmp/parallel.tar.bz2'
tar -C /tmp -xf $source
pushd /tmp/parallel-* > /dev/null
./configure
make
sudo make install
popd > /dev/null
}
download_sublime ()
{
local source='/tmp/sublime3.tgz'
wget -q -O $source \
http://c758482.r82.cf2.rackcdn.com/sublime-text_build-3065_amd64.deb
}
install_sublime ()
{
local source='/tmp/sublime3.tgz'
sudo dpkg -i $source
rm $source
}
#### SANITY CHECK ####
# don't bother updating yet
pkill -f /usr/bin/update-manager
#### AUTOPILOT ####
# start custom downloads
if [ vagrant == "$USER" ]; then
download_atom &
download_docker_ssh &
download_font_microsoft &
download_font_noto &
download_font_powerline &
download_font_source_code_pro &
download_font_source_sans_pro &
download_font_source_serif_pro &
download_lmutil &
download_parallel &
download_sublime &
fi
# pull docker baseimage in background (specifically leave out sudo)
docker pull phusion/baseimage:latest >/dev/null &
# uninstall some unneeded stuff to save time and space
sudo apt-get purge -y --auto-remove \
abiword-common \
gmusicbrowser \
gnumeric-common \
gnumeric-doc \
libabiword-3.0 \
parole \
pidgin-data \
pidgin-otr \
simple-scan \
software-center-aptdaemon-plugins \
thunderbird \
transmission-common \
xfburn \
`#end`
# dist-upgrade
sudo apt-get update
sudo apt-get dist-upgrade -y
# apt-file, good to cache (do these two together to avoid dialog box)
sudo apt-get install -y apt-file
sudo apt-file update >/dev/null &
# tier 1: BAP + IDA + LLVM (building tools) + qira (exo-docker) + cross compiler
sudo apt-get install -y \
`#BAP` \
binutils-multiarch-dev `#ocamlobjinfo cmxs` \
libgmp-dev `#zarith` \
libiberty-dev `#ocamlobjinfo cmxs` \
libncurses5-dev `#ocamlfind` \
ocaml \
opam \
`#BAP depext` \
clang \
libcurl4-gnutls-dev \
libgmp-dev `#zarith` \
libzip-dev \
llvm \
llvm-3.4-dev \
m4 `#ocamlfind` \
time \
zlib1g-dev \
`#IDA` \
libqtgui4:i386 \
lsb-core `#lmutil` \
`#LLVM` \
cmake \
ninja-build \
`#qira` \
binfmt-support \
google-chrome-stable \
qemu-user-static \
qemu-utils \
socat \
`#cross` \
g++-4.8-multilib \
g++-aarch64-linux-gnu \
g++-arm-linux-gnueabihf \
g++-powerpc-linux-gnu \
g++-powerpc64le-linux-gnu \
gcc-arm-linux-gnueabi \
gdb-multiarch \
linux-libc-dev:i386 \
`#end`
# tier 2: good stuff that everyone should want in my opinion
sudo apt-get install -y \
aptitude \
augeas-tools \
bash-doc `#info` \
binutils-doc `#info` \
bison \
curl \
dos2unix \
emacs24 \
emacs24-el \
flex \
font-manager \
gawk \
gcc-doc `#info` \
git \
git-svn \
htop \
kdiff3-qt \
keychain \
libxml2-utils `#xmllint` \
mercurial \
moreutils `#sponge` \
mosh \
most \
ncdu \
nmap \
pigz \
pv \
python-pip \
realpath \
renameutils \
rlwrap \
screen \
silversearcher-ag \
sqlite \
ssh \
subversion \
terminator \
texinfo \
tig \
tmux \
tree \
vim-gtk \
xml2 \
`#end`
sudo chmod a+x $(locate git-new-workdir)
sudo ln -sf $(locate git-new-workdir) /usr/local/bin
# tier 3: CMU specific
sudo apt-get install -y debconf-utils
cat << "EOF" | sudo debconf-set-selections
krb5-config krb5-config/add_servers boolean false
krb5-config krb5-config/add_servers_realm string AEGIS.CYLAB.CMU.EDU
krb5-config krb5-config/admin_server string
krb5-config krb5-config/default_realm string AEGIS.CYLAB.CMU.EDU
krb5-config krb5-config/kerberos_servers string
krb5-config krb5-config/read_conf boolean true
EOF
sudo apt-get install -y \
krb5-user \
`#end`
# tier 4: postgresql
sudo apt-get install -y \
postgresql \
postgresql-client \
postgresql-contrib \
`#end`
# wait for bg downloads
echo 'Waiting for background downloads to finish...'
wait
# install custom stuff
if [ vagrant == "$USER" ]; then
install_atom
install_docker_ssh
install_font_microsoft
install_font_noto
install_font_powerline
install_font_source_code_pro
install_font_source_sans_pro
install_font_source_serif_pro
install_lmutil
install_parallel
install_sublime
sudo chmod -R og=u,og-w /usr/share/fonts
fi
# courtesy
sudo apt-get -y autoremove
sudo updatedb
if [ vagrant == "$USER" ]; then
sleep 15 #trigger xfsettingsd bug
calm_down
# final step: zero out empty space before packaging into a box
echo 'Zeroing empty space to reduce box size...'
echo '(can take several minutes on a large disk image)'
time sudo nice dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
# yay
cat << "EOF"
Shutdown VM and take Snapshot 2. Then, in the *host*, execute these commands
by substituting "XU64Base" with the name of this VM:
yourself@host$ vagrant package --base XU64Base --output /tmp/package.box
yourself@host$ vagrant box add --force versioning.json
(Remember that copy-and-paste works inside this VM.)
EOF
rm -f 2.sh
history -cw
fi