summaryrefslogtreecommitdiff
path: root/tasks/set_motd
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-24 21:05:27 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-24 21:05:27 +0100
commit8081a5520a441b43a8a7a73f3a90c7aacfaa8e10 (patch)
treec7f49bd33ed19d53afc0ee9df8b2c82c200c5910 /tasks/set_motd
parent9963b74f777edf985540eac71b1ca095f88b8bca (diff)
Move everything one level up
Diffstat (limited to 'tasks/set_motd')
-rw-r--r--tasks/set_motd/howtos/en/index.html44
-rw-r--r--tasks/set_motd/howtos/images/first.pngbin0 -> 3793 bytes
-rw-r--r--tasks/set_motd/howtos/images/img1.pngbin0 -> 64082 bytes
-rw-r--r--tasks/set_motd/howtos/images/img10.pngbin0 -> 27789 bytes
-rw-r--r--tasks/set_motd/howtos/images/img11.pngbin0 -> 2090 bytes
-rw-r--r--tasks/set_motd/howtos/images/img12.pngbin0 -> 4119 bytes
-rw-r--r--tasks/set_motd/howtos/images/img2.pngbin0 -> 64618 bytes
-rw-r--r--tasks/set_motd/howtos/images/img3.pngbin0 -> 63941 bytes
-rw-r--r--tasks/set_motd/howtos/images/img4.pngbin0 -> 54840 bytes
-rw-r--r--tasks/set_motd/howtos/images/img5.pngbin0 -> 12233 bytes
-rw-r--r--tasks/set_motd/howtos/images/img6.pngbin0 -> 33093 bytes
-rw-r--r--tasks/set_motd/howtos/images/img7.pngbin0 -> 32530 bytes
-rw-r--r--tasks/set_motd/howtos/images/img8.pngbin0 -> 17532 bytes
-rw-r--r--tasks/set_motd/howtos/images/img9.pngbin0 -> 23007 bytes
-rw-r--r--tasks/set_motd/howtos/images/second.pngbin0 -> 25542 bytes
-rw-r--r--tasks/set_motd/howtos/images/slika3.pngbin0 -> 21635 bytes
-rw-r--r--tasks/set_motd/howtos/images/slika4.pngbin0 -> 17317 bytes
-rw-r--r--tasks/set_motd/howtos/si/index.html46
-rw-r--r--tasks/set_motd/task.py86
19 files changed, 176 insertions, 0 deletions
diff --git a/tasks/set_motd/howtos/en/index.html b/tasks/set_motd/howtos/en/index.html
new file mode 100644
index 0000000..2987cc5
--- /dev/null
+++ b/tasks/set_motd/howtos/en/index.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>set_motd</title>
+ <meta charset="utf-8">
+</head>
+<body>
+<h1>set_motd</h1>
+<h2>Purpose of the exercise</h2>
+<p>How to create user? How to edit a file? How to connect to anoter computer using ssh? How to find out the computer IP address?</p>
+<h2>Brief description</h2>
+<p>Set up two virtual machines, set MOTD. Connect using ssh.</p>
+
+<h2>How To</h2>
+
+<ol>
+ <li>Create two virtual machines, Student(student-console) and Test(SimpleArbiterDhcpGw) <br> <img src="../images/img4.png" alt="no img"></li>
+ <li>Change the network settings to both virtual machines. SimpleArbiterDhcpGw: Adapter 1 set it to NAT for internet access, Adapter 2 to internal network for local network.
+ Student: Adapter1 set it to "internal-network" so it is in the same domestic network as SimpleArbiterDhcpGw. <br> <img src="../images/img1.png" alt="no img"> <br> <img src="../images/img2.png" alt="no img"> <br> <img src="../images/img3.png" alt="no img"></li>
+ <li>Login on <b>Student</b> <br> <img src="../images/img5.png" alt="no img"></li>
+ <li>On Student(student-console) create a new user (with "adduser username", as the task demands of you ( eg. marjankoral19 ), with a custom password. <br> <img src="../images/img6.png" alt="no img"></li>
+ <li>In Student(student-console) open interfaces file ( nano /etc/network/interfaces ) and set the IP <br>
+ <h2>How to use the <strong>nano</strong> text editor </h2>
+ <p>
+ 1.) Open the nano editor with the command nano, which is followed by the path and name of the file. Example: <strong>nano /etc/myfile</strong>. If the file doesn't exist, the file will be created by the editor.<br />
+ 2.) To move in the editor, we use the arrow keys, <strong>backspace</strong> is used for deleting. <br />
+ 3.) To save a file press the combination of keys <strong>ctrl</strong> + <strong>O</strong>. <br />
+ 4.) To exit the editor press the combination of keys <strong>ctrl</strong> + <strong>X</strong>. The editor will ask you, if you really want to exit, you can answer with <strong>y</strong> (yes ) or with <strong>n</strong> ( no ). <br />
+ 5.) To cut a line press the combination of keys <strong>ctrl</strong> + <strong>K</strong>. <br />
+ 6.) To paste a line press the combination of keys <strong>ctrl</strong> + <strong>U</strong>. <br />
+ 7.) To search over a document press the combination of keys <strong>ctrl</strong> + <strong>W</strong> and then enter the search string.
+ </p> <img src="../images/img7.png" alt="no img" ></li>
+ <li>We can check which interface belongs to which adapter in Virtual-box with MAC address. Run ifconfig command and compare the HWaddr value with the value in the Virtual-box ( settings => network => adapter => Mac address ) <br /><img src="../images/slika4.png" alt="no img" /><img src="../images/slika3.png" alt="no img"/></li>
+ <li>Then edit the /etc/motd (eg. with nano editor like this: "nano /etc/motd"), file with the specified string. (eg. "Not for Human consumption" ) <br> <img src="../images/img8.png" alt="no img"> </li>
+ <li>For testing, login with the test user into Test(SimpleArbiterDhcpGw) <br> <img src="../images/img9.png" alt="no img"></li>
+ <li>Then connect to the Student with ssh, using the user marjankoral19 - ssh marjankoral@ip. <br> <img src="../images/img10.png" alt="no img"></li>
+ <li>If the login was successful, the Message of the day should apear.</li>
+ <li>To run Kpov_judge, login onto SimpleArbiterDhcpGw, find and run the file test_task.py ( with ./test_task.py as all other scripts )<br /> <img src="../images/img11.png" alt="no img"></li>
+ <li>A window appears as we can see on the image above, then press Enter, enter your username ( eg. dr6784@student.uni-lj.si ), password, task name (eg. 01-preparation-set_motd), enter the string we should get in motd, enter the username and password of a user on Student(student-console)(eg. marjankoral19), the IP of Student(student-console), and after a brief moment we should get the result. <img src="../images/img12.png" alt="no img"> </li>
+</ol>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/tasks/set_motd/howtos/images/first.png b/tasks/set_motd/howtos/images/first.png
new file mode 100644
index 0000000..d3797d7
--- /dev/null
+++ b/tasks/set_motd/howtos/images/first.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img1.png b/tasks/set_motd/howtos/images/img1.png
new file mode 100644
index 0000000..2ed7899
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img1.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img10.png b/tasks/set_motd/howtos/images/img10.png
new file mode 100644
index 0000000..dca77ef
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img10.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img11.png b/tasks/set_motd/howtos/images/img11.png
new file mode 100644
index 0000000..f42e7b0
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img11.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img12.png b/tasks/set_motd/howtos/images/img12.png
new file mode 100644
index 0000000..73ffb65
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img12.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img2.png b/tasks/set_motd/howtos/images/img2.png
new file mode 100644
index 0000000..51688ac
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img2.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img3.png b/tasks/set_motd/howtos/images/img3.png
new file mode 100644
index 0000000..93a8acf
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img3.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img4.png b/tasks/set_motd/howtos/images/img4.png
new file mode 100644
index 0000000..e5e21f9
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img4.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img5.png b/tasks/set_motd/howtos/images/img5.png
new file mode 100644
index 0000000..a128781
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img5.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img6.png b/tasks/set_motd/howtos/images/img6.png
new file mode 100644
index 0000000..b10bf9a
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img6.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img7.png b/tasks/set_motd/howtos/images/img7.png
new file mode 100644
index 0000000..40ce63d
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img7.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img8.png b/tasks/set_motd/howtos/images/img8.png
new file mode 100644
index 0000000..b7bd3b8
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img8.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/img9.png b/tasks/set_motd/howtos/images/img9.png
new file mode 100644
index 0000000..20a2439
--- /dev/null
+++ b/tasks/set_motd/howtos/images/img9.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/second.png b/tasks/set_motd/howtos/images/second.png
new file mode 100644
index 0000000..61bea73
--- /dev/null
+++ b/tasks/set_motd/howtos/images/second.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/slika3.png b/tasks/set_motd/howtos/images/slika3.png
new file mode 100644
index 0000000..05ca178
--- /dev/null
+++ b/tasks/set_motd/howtos/images/slika3.png
Binary files differ
diff --git a/tasks/set_motd/howtos/images/slika4.png b/tasks/set_motd/howtos/images/slika4.png
new file mode 100644
index 0000000..b99df06
--- /dev/null
+++ b/tasks/set_motd/howtos/images/slika4.png
Binary files differ
diff --git a/tasks/set_motd/howtos/si/index.html b/tasks/set_motd/howtos/si/index.html
new file mode 100644
index 0000000..601b667
--- /dev/null
+++ b/tasks/set_motd/howtos/si/index.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>set_motd</title>
+<meta charset="utf-8">
+</head>
+<body>
+<h1>set_motd</h1>
+<h2>Namen vaje</h2>
+<p>Kako se ustvari uporabnik? Kako se popravi datoteka? Kako se s pomočjo ssh
+povežemo na drug racunalnik? Kako ugotovimo IP naslov računalnika? </p>
+
+<h2>Naloga na hitro</h2>
+<p>Postavi 2 navidezna računalnika, nastavi MOTD. Poveži se preko ssh.</p>
+
+<h2>Podrobna navodila</h2>
+
+<ol>
+ <li>Ustvari dva navidezna računalnika, računalnik Student(student-console) ter računalnik Test(SimpleArbiterDhcpGw) <br> <img src="../images/img4.png" alt="ni slike"></li>
+ <li>Spremeni omrežne nastavitve obema navideznima računalnikoma, SimpleArbiterDhcpGw: Adapter 1 na NAT za dostop do interneta, Adapter 2 na "internal network" za lokalno omrežje,
+ Student: Adapter1 na internal-network, da je v enakem omrežju kot SimpleArbiterDhcpGw. <br> <img src="../images/img1.png" alt="ni slike" > <br> <img src="../images/img2.png" alt="ni slike"> <br> <img src="../images/img3.png" alt="ni slike"></li>
+ <li>Prijavi se na računalniku Student. <br> <img src="../images/img5.png" alt="ni slike"></li>
+ <li>Na računalniku Student(student-console) ustvari novega uporabnika (z ukazom "adduser imeuporabnika"), kot to od tebe zahteva naloga (npr. marjankoral19), geslo določi sam. <br> <img src="../images/img6.png" alt="ni slike"></li>
+ <li>Računalnik Student, odpri datoteko interfaces ( nano /etc/network/interfaces ), ter nastavi IP. <br> <img src="../images/img7.png" alt="ni slike"></li>
+ <h2>Kako se uporablja <strong>nano</strong> urejavalnika besedila: </h2>
+ <p>
+ 1.) Urejvalnik Nano odpremo z ukazom nano, kateremu sledi ime datoteke. Primer: <strong>nano /etc/mojadatoteka</strong>. Če datoteka ne obstaja jo bo ustvaril urejevalnik. <br />
+ 2.) Po urejevalniku se premikamo s smernimi puščicami, brišemo s tipko <strong>backspace</strong>. <br />
+ 3.) Za shranjevanje dokumenta pritisnemo kombinacijo tipk <strong>ctrl</strong> + <strong>O</strong> <br />
+ 4.) Za izhod iz urejevalnika pritisnemo kombinacijo tipk <strong>ctrl</strong> + <strong>X</strong>. Pri tem nas urejevalnik upraša, če želimo shraniti spremembe. Odgovorimo z <strong>y</strong> (yes, ja ) ali z <strong>n</strong> ( no, ne ). <br />
+ 5.) Za izrez vrstice uporabimo kombinacijo tipk <strong>ctrl</strong> + <strong>K</strong>. <br />
+ 6.) Za lepljenje vrstice se uporablja kombinacija tipk <strong>ctrl</strong> + <strong>U</strong>. <br />
+ 7.) Za iskanje po besedilu uporabimo kombinacijo tipk <strong>ctrl</strong> + <strong>W</strong>, nakar vnesemo iskani niz in pritisnemo tipko enter.
+ </p><br />
+ <li>Kateri vmesnik (npr. eth0) spada pod kateri adapter (npr. Adapter1 ), lahko preverimo s strojnimi naslovi. Na računalniku zaženemo ukaz ifconfig, pogledamo HWaddr vrednost ter jo primerjamo z vrednostjo v Virtual-boxu (nastavitve => omrežja => adapter => MAC address <br /><img src="../images/slika4.png" alt="ni slike"/><img src="../images/slika3.png" alt="ni slike"/></li>
+ <li>Nato spremeni datoteko /etc/motd (z urejevalnikom nano, primer uporabe: "nano /etc/motd"), ter zamenjaj niz z ustreznim nizom kot to od tebe zahteva naloga ( npr. "Not for Human consumption" ) <br>
+ <img src="../images/img8.png" alt="ni slike"> </li>
+ <li>Za testiranje se s testnim uporabniškim imenom prijavi na prvem računalniku. (SimpleArbiterDhcpGw) <br> <img src="../images/img9.png" alt="ni slike"></li>
+ <li>Nato se preko ssh poveži na računalnik Student z uporabniškim imenom marjankoral19 - ssh marjankoral19@ip. <br> <img src="../images/img10.png" alt="ni slike" ></li>
+ <li>Po uspešni prijavi se bi moralo izpisati motd sporočilo.</li>
+ <li>Kpov_judge poženemo tako da se prijavimo na računalniku SimpleArbiterDhcpGw, najdemo datoteko test_task.py ter jo poženemo ( z ./test_task.py kot se poganjajo vse skripte )<br /> <img src="../images/img11.png" alt="ni slike"></li>
+ <li>Pojavi se nam okno kot ga vidimo zgoraj, nato pa pritisnemo tipko Enter, vnesemo svoje uporabniško ime ( npr. dr6784@student.uni-lj.si ), geslo, ime naloge (npr. 01-preparation-set_motd), vnesemo niz ki bi se nam moral prikazati, vnesemo ime uporabnika na računalniku Student (npr. marjankoral19) ter njegovo geslo, ip računalnika študent, nato pa po kratkem premoru dobimo rezultat. <img src="../images/img12.png" alt="ni slike"> </li>
+</ol>
+
+</body>
+</html> \ No newline at end of file
diff --git a/tasks/set_motd/task.py b/tasks/set_motd/task.py
new file mode 100644
index 0000000..89b78f6
--- /dev/null
+++ b/tasks/set_motd/task.py
@@ -0,0 +1,86 @@
+instructions = {
+ 'si': '''\
+<p>
+Ustvari dva navidezna računalnika - imenujmo ju <em>arbiter</em> in <em>student</em>.
+Na računalniku <em>student</em> ustvarite uporabnika z uporabniškim imenom <code>{{peer_user}}</code>. IP navideznega računalnika <em>student</em> ter geslo za uporabnika <code>{{peer_user}}</code> nastavite sami.
+
+<p>
+Poskrbite, da se bo v sporočilu, ki se ob prijavi izpiše na računalniku <em>student</em>, pojavil niz
+
+<pre><code>{{niz}}</code></pre>
+
+<p>
+Temu sporočilu v angleščini rečemo <em lang="en">message of the day</em> oziroma <em>MOTD</em>. Ocenjevalni program pričakuje, da se bo ob koncu prijave pojavila ukazna vrstica oblike
+
+<pre><code>username@hostname:~$ </code></pre>
+
+Pazite, da se bo takšna vrstica pojavila šele po nizu, ki ste ga dobili v teh navodilih.
+ ''',
+ 'en': '''\
+<p>
+Create two virtual machines named <em>arbiter</em> and <em>student</em>. On <em>student</em>, create a user with the username <code>{{peer_user}}</code>. Set the IP of <em>student</em> and the password for <code>{{peer_user}}</code> yourself.
+
+<p>
+Set the <em>message of the day</em> (MOTD) on <em>student</em> to
+
+<pre><code>{{niz}}</code></pre>
+
+<p>
+This is the message which is displayed when you log in. The grading system expects that after login a prompt similar to
+
+<pre><code>username@hostname:~$ </code></pre>
+
+<p>
+appears. Make sure that this line shows up only after the string you got in these instructions.
+'''
+}
+
+computers = {
+ 'arbiter': {
+ 'disks': [{'name': 'dhcp-gw'}],
+ 'flavor': 'm1.tiny',
+ 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}],
+ 'config_drive': True,
+ 'userdata': {'string': "#!/bin/bash\nsed -i '/cloud/d' /etc/fstab\npoweroff &\n"}
+ },
+ 'student': {
+ 'disks': [{ 'name': 'console'}],
+ 'flavor': 'm1.tiny',
+ 'network_interfaces': [{'network': 'net1'}],
+ 'config_drive': True,
+ 'userdata': {'string': "#!/bin/bash\nsed -i '/cloud/d' /etc/fstab\npoweroff &\n"}
+ }
+}
+
+networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
+
+params_meta = {
+ 'peer_ip': {'descriptions': {'si': 'IP računalnika', 'en':'IP'}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
+ 'peer_user': {'descriptions': {'si': 'ime uporabnika', 'en':'Username'}, 'w': False, 'public': True, 'type': 'username', 'generated': True},
+ 'peer_passwd': {'descriptions': {'si': 'geslo uporabnika', 'en': 'Password'}, 'w': True, 'public': True, 'type': 'alnumstr', 'generated': False},
+ 'niz': {'descriptions':{'si': 'niz, ki naj se v motd pokaže', 'en': 'The string which should be displayed in the MOTD'}, 'w': False, 'public': True, 'type': 'short_text', 'generated': True},
+}
+
+def task(peer_ip, peer_user, peer_passwd, niz):
+ "Check whether ssh works and return the MOTD."
+ return kpov_util.ssh_test(peer_ip, peer_user, peer_passwd)
+
+def gen_params(user_id, params_meta):
+ return kpov_util.default_gen(user_id, params_meta)
+
+def task_check(results, params):
+ niz = params['niz']
+ score = 0
+ hints = []
+ if results['ssh'] is True:
+ score += 4
+ if niz in results['motd']:
+ score += 6
+ else:
+ hints += ['wrong motd:\n' + results['motd'] + '\n']
+ else:
+ hints += ['ssh failed: ' + results['ssh']]
+ return score, hints
+
+def prepare_disks(templates, task_params, global_params):
+ write_default_config(templates['dhcp-gw'], global_params)