-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathvirtualbox-image-details.html
More file actions
585 lines (585 loc) · 27.9 KB
/
Copy pathvirtualbox-image-details.html
File metadata and controls
585 lines (585 loc) · 27.9 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
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>VirtualBox image creation details</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
/* The extra [class] is a hack that increases specificity enough to
override a similar rule in reveal.js */
ul.task-list[class]{list-style: none;}
ul.task-list li input[type="checkbox"] {
font-size: inherit;
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<link rel="stylesheet" href="../markdown.css" />
</head>
<body>
<main>
<h1 id="virtualbox-image-creation-details">VirtualBox image creation
details</h1>
<p><a href="index.html">Go up to the main directory page</a> (<a
href="index.md">md</a>)</p>
<p>For those who are interested, this is how the VirtualBox image was
created.</p>
<p>These directions are duplicated in multiple repositories, as they all
use the same image. Those are:</p>
<ul>
<li><a
href="https://github.com/aaronbloomfield/slp">aaronbloomfield/slp</a>
(docs directory)</li>
<li><a href="https://github.com/markfloryan/pdr">markfloryan/pdr</a>
(tutorial 1)</li>
<li><a
href="https://github.com/aaronbloomfield/dada">aaronbloomfield/dada</a>
(docs directory)</li>
<li><a href="https://github.com/uva-acm/hspc">uva-acm/hspc</a> (common
directory)</li>
</ul>
<h1 id="introduction">Introduction</h1>
<p>This page has a number of different sections, and the sections you
need to install will vary depending on what you are using this image
for. The image provided with the class has only two sections not
installed: Dropbox configuration (in “Image completion”) and Turning of
the Internet access (in “Programming Contest configuration”).</p>
<p>The top of each section describes which of the sub-sections need to
be installed for what.</p>
<p><strong>Software Versions</strong></p>
<p>This installation document installs the following versions:</p>
<ul>
<li><a href="http://kubuntu.org/getkubuntu/">Kubuntu 16.04,
64-bit</a></li>
<li>Clang++ version 3.8.0</li>
<li>Python <a
href="http://packages.ubuntu.com/xenial/python3">3.5.2</a>; <a
href="https://www.djangoproject.com/download/">Django 1.11</a></li>
<li><a href="https://gorails.com/setup/ubuntu/16.04">Ruby 2.4.1; Rails
5.1.3</a></li>
</ul>
<p>Newer versions of the above may have since come out, but at the time
of the writing of this document (August 2017), they were either the
versions installed via apt-get (Clang, Python), or the latest versions
installed manually (Django, Ruby, and Rails).</p>
<p><strong>Notes</strong></p>
<ul>
<li>The guest hard drive reported 9.3 Gb of space available, prior to
distribution of the image. The disk image itself was, after compaction,
7.6 Gb. When compressed via zip, it was 2.6 Gb in size.</li>
<li>You will likely need to use a different unzip program to extract the
image; the ones that come bundled with most operating systems can not
handle archives of that size. We have used <a
href="http://www.7-zip.org/">7-zip</a> with success.</li>
<li>Video and sound (via youtube) worked fine with Chrome</li>
<li>The VM may capture the mouse - to uncapture it, you press the “host
key”, (which is the right Control key on Linux and Windows hosts, and
the left Command key on Mac hosts). To have it warn you about what this
is, you can reset all warnings via the VirtualBox help menu, and it will
warn you about this at boot-up</li>
<li>In the image creation process, you may run into a problem with
VirtualBox where it cannot register a new (or different) disk because it
has the same UUID as a previous disk that you are replacing. If so, then
the command <code>VBoxManage internalcommands sethduuid disk.vdi</code>
(changing <code>disk.vdi</code> appropriately) will change the UUID, and
allow you to proceed</li>
</ul>
<h1 id="basic-installation">Basic installation</h1>
<p>All installations need to run through this, as it sets up the default
Kubuntu installation.</p>
<p><strong>Basic installation</strong></p>
<ul>
<li>Created a new VirtualBox image
<ul>
<li>I named it “Kubuntu 16.04” or similar; this automatically selected
Linux as the OS type; I manually selected “Ubuntu (64 bit)” as the
version</li>
<li>I set the memory at 1536 Mb (instead of the default of 512 Mb),
ensured that the disk size was “dynamically allocated” and was set to 20
Gb (instead of the default 8 Gb); everything else was set at the
default</li>
</ul></li>
<li>I installed Kubuntu 16.04.1 LTS (64 bit), desktop edition, from the
DVD image downloaded from <a
href="http://www.kubuntu.org/getkubuntu">http://www.kubuntu.org/getkubuntu</a>
(the specific image file is <a
href="http://cdimage.ubuntu.com/kubuntu/releases/16.04.1/release/kubuntu-16.04.3.desktop-amd64.iso">here</a>)
<ul>
<li>When prompted, I clicked on ‘download updates’ and ‘install 3rd
party software’ when the options were given</li>
<li>For hard drive, I used the default: “Guided – use entire disk”</li>
<li>The computer name is cassiopeia, the login name is ‘student’, full
name is ‘L33t H4x0r’, and the password is ‘password’</li>
<li>This account can run root (system) commands via ‘sudo’ - if you
don’t know what this means, you can safely ignore it</li>
</ul></li>
<li>Once it was finished, I rebooted, and logged in</li>
<li>Via a Konsole, ran <code>sudo apt-get update</code> then
<code>sudo apt-get dist-upgrade</code></li>
<li>Reboot!</li>
<li>Ran <code>apt-get autoremove</code> (which didn’t have to remove
anything)</li>
<li>VirtualBox guest additions
<ul>
<li>These are the utilities so that VirtualBox will work correctly with
the host computer (proper full screen, etc.)</li>
<li>From the VirtualBox Device menu, select “Insert Guest Additions CD
Image”, and follow the prompts</li>
<li>Once done, run <code>autorun.sh</code> from
<code>/media/student/VBOXADDITIONS_4.3.36_105129</code> (or similar),
and follow the prompts. Alternatively, if that does not work, try
running <code>sudo bash VBoxLinuxAdditions.run</code> from that same
directory.</li>
</ul></li>
<li>Reboot!</li>
</ul>
<h1 id="development-installation">Development installation</h1>
<p>The “Program and Data Representation configuration” section is for
the <a href="http://markfloryan.github.io/pdr">Program and Data
Representation</a> course, and it includes all of the compilers and
editors needed. The “Python/Django” section installs the files needed to
run Python 3 and the Django framework. The “Ruby on Rails configuration”
section is for developing Ruby on Rails software.</p>
<p><strong>Program and Data Representation configuration</strong></p>
<ul>
<li>Installed the other packages:
<code>sudo apt-get install clang emacs24 vim nasm astyle tofrodos source-highlight gdb lldb doxygen doxygen-doc graphviz ddd git g++ python-gpgme gobjc gnustep gnustep-make gnustep-common libgnustep-base-dev evince g++-multilib libc6-dev-i386 libc6-dev:i386 flex</code>
<ul>
<li>Note that there are two other <code>apt-get install</code> lines to
be run, below</li>
<li>The python-gpgme package is a supporting package for Dropbox, in
case students want to install that</li>
<li>The last 5 packages are for Objective C, based on the instructions
<a
href="http://www.fatvat.co.uk/2010/04/getting-started-with-objective-c-on.html">here</a>
(it may be that only a subset of those packages are actually
necessary)</li>
</ul></li>
<li>Ran the following two commands to change the default C/C++ compiler
to clang:</li>
</ul>
<pre><code>sudo update-alternatives --set cc /usr/bin/clang
sudo update-alternatives --set c++ /usr/bin/clang++</code></pre>
<ul>
<li>Downloaded Google Chrome from <a
href="https://www.google.com/chrome/browser/desktop/index.html">here</a>,
and installed it via
<code>sudo dpkg -i google-chrome-stable_current_i386.deb</code>
<ul>
<li>That installation did not work perfectly (which was expected), and
to fix an installation such as this you run
<code>sudo apt-get -f install</code></li>
<li>Then the .deb file was removed</li>
</ul></li>
<li>Added konsole, emacs, and google chrome icons to favorites (from the
K (start) menu, right-click and select ‘add to favorites’), and the task
bar (from the favorites menu, right-click and select ‘add to panel’;
this may require right-clicking on the panel and selecting panel options
-> panel settings prior to moving the icons)</li>
<li>Browser customization
<ul>
<li>Set both Chrome’s home page to Collab</li>
<li>Added the http://markfloryan.github.io/pdr/uva/index.html page as
the second tab loaded up by Chrome</li>
<li>Chrome is set as the default browser</li>
</ul></li>
<li>I loaded up emacs from the command line, and then told it to disable
showing the startup messages (this could also be accomplished by
following the guidelines <a
href="http://xenon.stanford.edu/~manku/dotemacs.html">here</a>).</li>
<li>Added a few aliases were added (the last 4 lines of .bashrc) to help
prevent people from accidentally removing files (adding -i for rm, mv,
and cp; and aliasing xemacs to emacs). This was done both in
/home/student/.bashrc and /etc/skel/.bashrc.</li>
</ul>
<pre><code>alias mv='mv -i'
alias rm='rm -i'
alias cp='cp -i'
alias xemacs='emacs'</code></pre>
<ul>
<li>Cloned the github repo via
<code>git clone https://github.com/markfloryan/pdr</code>; note that a
<code>git pull</code> will still have to be executed each time to update
it</li>
<li>Removed all the empty default directories in ~/student other than
Desktop and Downloads</li>
<li>Changed the auto-lock feature: K-menu -> Computer -> System
Settings -> Desktop Behavior -> Screen Locking, uncheck the “lock
screen automatically…” button, and click Apply.</li>
<li>Plasmashell, which is part of the graphical window system, was
crashing repeatedly. The reason seems to be tooltip previews of
application windows, so these should be disabled: right click taskbar
-> Task Manager Settings -> General -> Uncheck “show
tooltips”</li>
</ul>
<p><strong>LAMP configuration (with both PHP and Python 3)</strong></p>
<ul>
<li>Installed more packages:
<code>sudo apt-get install apache2 php php-cli netbeans phpmyadmin phpunit libmysqlclient-dev mysql-server mysql-client php-mysql default-jdk openssh-server tk-dev python-mysqldb php-mcrypt php-intl python3-pip composer libapache2-mod-php sqlite3 postgresql postgresql-contrib</code>
<ul>
<li>any prompted passwords (such as mysql) are ‘password’</li>
<li>anything that needed configuration with a web server (phpmyadmin,
for example) is only configured with the apache2 server</li>
<li>once done, ran <code>sudo -H pip3 install --upgrade pip</code></li>
<li>ran <code>sudo apt-get remove openjdk-8-doc</code>, since that takes
up a lot of space and can be accessed on the Internet</li>
</ul></li>
<li>apache2 configuration
<ul>
<li>enabled the userdir apache2 module (i.e., using ~userid/ for each
userid): <code>sudo a2enmod userdir</code></li>
<li>enabled the URL rewriting apache2 module:
<code>sudo a2enmod rewrite</code></li>
<li>enabled the two PHP modules needed for the CakePHP framework:
<code>sudo phpenmod intl</code> and
<code>sudo phpenmod mcrypt</code></li>
<li>enabled PHP in user directories: edit (via sudo)
<code>/etc/apache2/mods-available/php7.0.conf</code>, and change the
<code>Off</code> in the <code>php_admin_value engine Off</code> line to
<code>On</code></li>
<li>restart apache: <code>sudo service apache2 restart</code></li>
<li>the ‘student’ user can already view the apache2 error logs (in
/var/log/apache2), but if they couldn’t, then they would have to have
been added to the ‘adm’ group (i.e.,
<code>usermod -a -G adm student</code>, but this requires logging out
and logging in for the group change to take effect)</li>
<li>made a ‘public_html’ directory both in ~student and /etc/skel; the
former is chown’ed to student:student</li>
</ul></li>
<li>ssh’ed to localhost to accept the ssh key</li>
<li>Installed Django: the version of Django installed via apt-get is
old, so we will install via pip:
<code>sudo -H pip install Django==1.11</code></li>
<li>Attempted a CakePHP installation, to ensure that composer worked,
and also to pre-download the files that would be used:
<code>composer create-project --prefer-dist cakephp/app test</code>. The
directory created was then deleted</li>
<li>Installed the virtualenv Python package:
<code>sudo -H pip install virtualenv</code></li>
</ul>
<p><strong>Ruby on Rails configuration</strong></p>
<ul>
<li>This method will take up about 200 Mb in your home directory; it
installs the files locally, not system-wide.</li>
<li>First, switch the C/C++ compiler back to gcc/g++:</li>
</ul>
<pre><code>sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --set c++ /usr/bin/g++</code></pre>
<ul>
<li>I then followed the directions at <a
href="https://gorails.com/setup/ubuntu/16.04">https://gorails.com/setup/ubuntu/16.04</a>.
The versions I used were Ruby 2.4.1, and Rails 5.1.3 (at the time of
this document’s writing); newer versions may have since appeared.
<ul>
<li>The rbenv installation method for Ruby was used</li>
<li>The git/github configuration step was skipped, as that requires the
final user of the image</li>
<li>MySQL was already set up in the LAMP configuration section</li>
<li>PostgreSQL is another SQL database, but we are not using that on the
image</li>
<li>The <code>--no-ri --no-rdoc</code> flags were added to each
<code>gem</code> command</li>
</ul></li>
<li>To start rails application, execute the following commands (the edit
to be done in emacs is listed below):</li>
</ul>
<pre><code>cd
rails new myapp -d mysql
cd myapp
emacs config/database.yml
rake db:create
rails server</code></pre>
<pre><code>- When you edit config/database.yml, you should change the mysql password (line 17 or so) to the root mysql user's password (likely just 'password')
- You can now view the rails app at http://localhost:3000 in your web browser</code></pre>
<ul>
<li>Changed the C/C++ compiler back over to clang/clang++:</li>
</ul>
<pre><code>sudo update-alternatives --set cc /usr/bin/clang
sudo update-alternatives --set c++ /usr/bin/clang++</code></pre>
<h1 id="programming-contest-configuration-sections">Programming Contest
configuration sections</h1>
<p>These sections are for configuring the image to run a programming
contest using <a href="http://www.ecs.csus.edu/pc2/">PC^2</a>, and are
not needed if you are <em>not</em> running (or participating in) such a
contest. One of the sections below will detail how to turn off the
Internet for use in the actual contest, and that should only be
completed for the final contest image.</p>
<p><strong>Programming Contest configuration</strong></p>
<ul>
<li>If you are upgrading from a previous image version, run
<code>sudo apt-get update</code> and then
<code>sudo apt-get dist-upgrade</code></li>
<li>Install the packages:
<code>sudo apt-get install emacs24 vim eclipse g++ git gdb openjdk-8-jdk gedit</code>
<ul>
<li>If the Basic Installation section, above, was installed, then some
of these packages have already been installed</li>
<li>The openjdk-8-doc package is not installed here to keep the image
size down, but the packages above install it anyway</li>
<li>For various reasons, the eclipse package is typically not installed
on the image released to the students, but should be installed on the
final contest image</li>
</ul></li>
<li>Download the latest <a href="http://www.ecs.csus.edu/pc2/">PC^2</a>
software and unzip it in /usr/local/
<ul>
<li>At the time of this writing, the latest version is 9.3.2-3449, and
the direct download link is <a
href="http://www.ecs.csus.edu/pc2/code/v9/pc2-9.3.2-3449/pc2-9.3.2-3449.zip">here</a>;
thus, the directory it is unzipped into would be
<code>/usr/local/pc2-9.3.2</code></li>
<li>After unzipping, create a symlink: from /usr/local/ run (changing
the version as necessary): <code>sudo ln -s pc2-9.3.2 pc2</code></li>
<li>Edit /usr/local/pc2/pc2v9.ini and replace <code>localhost</code> on
the <code>server</code> line (likely line 12) with the full server name
of the primary submission server</li>
</ul></li>
<li>Create a script to restore the Internet access after the contest
(this does not hurt anything to have it ready, as it won’t do anything
if the Internet is not turned off). This can be
<code>/usr/local/bin/restore-internet</code> – the commands therein need
sudo, so only the <code>student</code> user can run them. This is
typically executed at the end of the contest if the contestants want to
save their work. All that has to be done is to modify the default policy
for the chains. Be sure to also run
<code>chmod 755 /usr/local/bin/restore-internet</code>.</li>
</ul>
<pre><code>#!/bin/bash
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT</code></pre>
<ul>
<li>Create a <code>/usr/local/bin/pc2team</code> shell script, and chmod
that to 755 (<code>chmod 755 /usr/local/bin/pc2team</code>):</li>
</ul>
<pre><code>#!/bin/bash
cd
/bin/cp -f /usr/local/pc2/pc2v9.ini .
/usr/local/pc2/bin/pc2team &</code></pre>
<p><strong>User account configuration</strong></p>
<ul>
<li>Add in the four aliases to .bashrc, as described above in the “Basic
installation” section</li>
<li>Put the often used icons in the tool bar: Chrome or Firefox, Emacs,
Konsole (and Eclipse, if it is installed)</li>
<li>Load up Chrome and/or Firefox, and set the contest site as the
default home page</li>
<li>Load up emacs, click on “never show this again”, and then “dismiss
startup screen”; exit emacs</li>
<li>Remove all directories in the account other than Downloads and
Desktop</li>
<li>If there is a second user, then run <code>chmod 700 /home/*</code>
to prevent the second user from accessing any other user accounts (if
there is only one user account on the system, then this is not
necessary)</li>
<li>Create an icon in the task bar for pc2team (it may be easiest to use
an icon adapted from another application); use an <a
href="https://www.google.com/search?q=icpc+logo">appropriate logo</a>
for that</li>
</ul>
<p><strong>Turning off Internet access (and other things)</strong></p>
<ul>
<li>Prior to the contest itself, a bunch of things need to occur to the
image for it to work: Internet needs to be turned off, etc. These
modifications are <strong><em>NOT</em></strong> made to the image as
released, and should be made only right before the final image is
prepared for the contest.</li>
<li>If eclipse is not installed, then do so now
(<code>sudo apt-get install eclipse</code>); put that icon in the tool
bar</li>
<li>Edit /etc/hosts to allow that to resolve domain names to IP
addresses. Put in the course servers, their aliases, and their IP
addresses:</li>
</ul>
<pre><code>1.2.3.4 server1.university.edu server1
5.6.7.8 server2.university.edu server2
9.10.11.12 server3.university.edu server3</code></pre>
<ul>
<li>Configure iptables: this details how to turn <em>off</em> network
access. <strong>It is ONLY to be used on the final image for a
programming contest!!!</strong>
<ul>
<li>These directions based on the ones <a
href="https://help.ubuntu.com/community/IptablesHowTo">here</a> and <a
href="http://stackoverflow.com/questions/21870386/iptables-block-access-to-all-ports-except-from-a-partial-ip-address">here</a>.
We want to allow access to the submission servers, but deny everything
else. We set the policy to all three chains to DROP, and add ACCEPT
lines for localhost and the course servers for the INPUT and OUTPUT
chains (we don’t do anything, other than changing the default policy, to
the FORWARD chain). For example, the following commands will work
(assuming the servers are server1.cs.univeristy.edu through
server3.cs.university.edu):</li>
</ul>
<pre><code>iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -j ACCEPT -s server1.cs.university.edu
iptables -A INPUT -j ACCEPT -s server2.cs.university.edu
iptables -A INPUT -j ACCEPT -s server3.cs.university.edu
iptables -A OUTPUT -j ACCEPT -d server1.cs.university.edu
iptables -A OUTPUT -j ACCEPT -d server2.cs.university.edu
iptables -A OUTPUT -j ACCEPT -d server3.cs.university.edu
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP</code></pre>
<ul>
<li>Once those commands are entered via the command line, we save the
rules: <code>iptables-save > /etc/iptables.rules</code></li>
<li>After saving the rules, we configure the system to apply those rules
on boot (specifically, when bringing the network interface up). Edit
/etc/network/interfaces. There will only be a clause for lo (the
loopback interface) present. Under the
<code>iface lo inet loopback</code> line, put in the following line
(indented):
<code>pre-up iptables-restore < /etc/iptables.rules</code></li>
</ul></li>
<li><strong>IMPORTANT</strong>: having the contestants log in as
<code>student</code> is problematic, as that is the user that can
restore the Internet access (with the password and via
<code>sudo</code>). So either create another user, or change the
password to something else and have the contest staff log the students
in.
<ul>
<li>If you are creating a second user, be sure to run through the “user
account configuration” section, above</li>
<li>Let’s assume that the second user is <code>hspcteam</code>; once
this account is all set up, create an hspcteam backup to allow
resetting: from /home/student, run
<code>sudo /bin/cp -a /home/hspcteam .</code>; then enter the following
script (and make it executable) as
<code>/usr/local/bin/reset-hspcteam</code>:</li>
</ul>
<pre><code>#!/bin/bash
cd
sudo rsync -a --del hspcteam/ /home/hspcteam/</code></pre></li>
</ul>
<h1 id="image-completion">Image completion</h1>
<p>The “Installing Dropbox” section is not installed by default. The
“Image finalization” section should be run on every image. The other
sections largely deal with maintenance.</p>
<p><strong>Image finalization</strong></p>
<ul>
<li>I ran a few commands to make sure everything worked properly (and
deleted any created directories afterward):
<ul>
<li><code>composer create-project --prefer-dist cakephp/app cakephp</code></li>
<li><code>rails new railshw -d mysql</code></li>
<li><code>django-admin startproject mysite</code></li>
</ul></li>
<li>Reboot (rebooting also clears out /tmp)</li>
<li>Run <code>apt-get autoremove</code> and
<code>apt-get clean</code></li>
<li>Cleared browser history</li>
<li>To reduce the size of the hard disk (since I have to host it for
people to download), I ran
<code>sudo cat /dev/zero > zero; sudo /bin/rm -f zero</code>. This
creates a large file of all 0’s until it runs out of space, then removes
that file.</li>
<li>Ran <code>history -c</code> to remove the history of the commands
entered on the command line</li>
<li>Logged out then shut down the guest, and ran:
<code>VBoxManage modifyhd disk.vdi --compact</code> (using the real
image file name instead of “disk.vdi”). A better way would be to load up
into recovery mode and run zerofill, but the grub menu does not seem to
be easily available to load into recovery mode, so I didn’t pursue it
any further.</li>
</ul>
<p><strong>Installing Dropbox (optional)</strong></p>
<p><strong>NOTE:</strong> these instructions have not been tested for a
few years, so they may no longer work properly…</p>
<ul>
<li>If you want to install Dropbox, you can download the package from
https://www.dropbox.com/install</li>
<li>You want the 32-bit Ubuntu version from <a
href="https://www.dropbox.com/install?os=lnx">this page</a></li>
<li>Install it via <code>sudo dpkg -i dropbox_2015.02.12_i386.deb</code>
(adjust the package name to match what you just downloaded)</li>
<li>The installation will likely fail – that’s fine (there were likely
supporting packages needed). Two things to try:
<ul>
<li>Note that if you were installing this on your own computer, you
would need the python-gpgme package
(<code>sudo apt-get install python-gpgme</code>), but that was installed
already on the virtual box image</li>
<li>Run <code>sudo apt-get -f install</code> – the <code>-f</code> part
tells apt-get to install the packages needed to fix an installation</li>
</ul></li>
<li>To finish installing Dropbox, run <code>dropbox start -i</code>.
This will download and install the rest of the dropbox files needed</li>
<li>To start dropbox, run <code>dropbox start</code>. This first time it
will provide a link – once you go to that link, and log in, it will know
which account to link the computer to, and it will start downloading
your files.</li>
<li><strong>WARNING:</strong> Many people have a
<strong><em>lot</em></strong> of files in their Dropbox folder. And if
you have 8 Gb of files there, and you install Dropbox on your virtual
box image, then it will need to download 8 Gb of files. In addition to
taking quite some time, this will also cause the virtual box image to
take up an additional 8 Gb of space. And note that the VirtualBox image
is set to 20 Gb, and nearly 8 is taken up by the OS itself. So you may
want to increase the disk size, which brings us to…</li>
</ul>
<p><strong>Increasing the disk size</strong></p>
<p>The hard drive size was set at 20 Gb, and about 9.9 Gb is available;
the rest is used by the operating system (and the swap partition). If
you need more space than this, you will have to expand the hard drive.
Be careful – it is easy to accidentally erase the entire hard drive
while doing this!</p>
<ul>
<li>The process has two steps: increase the VirtualBox disk image
itself, then increase the partition of the guest OS.</li>
<li>To increase the VirtualBox disk image, power it down, and then run
the following command. The size listed is the size in Mb, so 20480 Mb is
20 Gb. The command is:
<code>VBoxManage modifyhd <imagefile> --resize 20480</code>
<ul>
<li>Note that <code><imagefile></code> is the .vdi disk image, and
should be the absolute path including the name and extension</li>
</ul></li>
<li>The second step is to resize the guest OS partition. The easiest way
to do this is to download a bootable disk image for this purpose. You
can use <a
href="http://sourceforge.net/projects/gparted/files/gparted-live-stable/">Gparted</a>,
which is free. Keep in mind that your guest OS is 32-bit, so you will
want the 386 (or 486 or 586) version.</li>
<li>To boot up via the Gparted image, Go to Settings -> Storage. In
the “Storage Tree” box, there will be a “Controller: IDE” entry, with an
“Empty” line below that; click on the “Empty” line, and select the
Gparted disk image (using the blue DVD icon on the right). Click Okay,
then start the image. It should start the Gparted disk.</li>
<li>When Gparted boots, selected the default boot option. In the
text-based menus, hit Enter to select the defaults.</li>
<li>From the GUI, resize your partition. Keep in mind that you will need
a 500 Mb swap partition. Hit “Apply” when done.</li>
<li>Double click on the red “Exit” icon, and select shutdown.</li>
<li>Back in Settings -> Storage -> Controller: IDE -> Empty,
remove that disk from the virtual CD/DVD drive (under the blue DVD icon,
select the last option to remove the image). Click OK.</li>
<li>Boot into Kubuntu normally.</li>
</ul>
<p><strong>Upgrading from a previous version</strong></p>
<p>Because previous versions of this image were a different version of
Ubuntu (specifically, 14.04), we are not providing upgrade information,
as it is too extensive to properly check those instructions.</p>
<p><strong>Changes for the future</strong></p>
<ul>
<li>An earlier version of this document (also from the fall 2017)
semester had a few packages missing; to install those, run:
<code>sudo apt-get install g++-multilib libc6-dev-i386 libc6-dev:i386 flex</code>
<ul>
<li>This document includes those packages</li>
</ul></li>
<li>Install a few things to ensure that python3 and django work with
mysql: <code>pip install mysqlclient</code> and
<code>apt-get install python3-mysqldb</code></li>
</ul>
</main>
</body>
</html>