You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

466 lines
16 KiB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  5. <head>
  6. <!-- 2023-03-23 Thu 23:57 -->
  7. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1" />
  9. <title>Lab8 Solution Amirlan Sharipov (BS21-CS-01)</title>
  10. <meta name="author" content="Amirlan Sharipov (BS21-CS-01)" />
  11. <meta name="generator" content="Org Mode" />
  12. <style>
  13. #content { max-width: 60em; margin: auto; }
  14. .title { text-align: center;
  15. margin-bottom: .2em; }
  16. .subtitle { text-align: center;
  17. font-size: medium;
  18. font-weight: bold;
  19. margin-top:0; }
  20. .todo { font-family: monospace; color: red; }
  21. .done { font-family: monospace; color: green; }
  22. .priority { font-family: monospace; color: orange; }
  23. .tag { background-color: #eee; font-family: monospace;
  24. padding: 2px; font-size: 80%; font-weight: normal; }
  25. .timestamp { color: #bebebe; }
  26. .timestamp-kwd { color: #5f9ea0; }
  27. .org-right { margin-left: auto; margin-right: 0px; text-align: right; }
  28. .org-left { margin-left: 0px; margin-right: auto; text-align: left; }
  29. .org-center { margin-left: auto; margin-right: auto; text-align: center; }
  30. .underline { text-decoration: underline; }
  31. #postamble p, #preamble p { font-size: 90%; margin: .2em; }
  32. p.verse { margin-left: 3%; }
  33. pre {
  34. border: 1px solid #e6e6e6;
  35. border-radius: 3px;
  36. background-color: #f2f2f2;
  37. padding: 8pt;
  38. font-family: monospace;
  39. overflow: auto;
  40. margin: 1.2em;
  41. }
  42. pre.src {
  43. position: relative;
  44. overflow: auto;
  45. }
  46. pre.src:before {
  47. display: none;
  48. position: absolute;
  49. top: -8px;
  50. right: 12px;
  51. padding: 3px;
  52. color: #555;
  53. background-color: #f2f2f299;
  54. }
  55. pre.src:hover:before { display: inline; margin-top: 14px;}
  56. /* Languages per Org manual */
  57. pre.src-asymptote:before { content: 'Asymptote'; }
  58. pre.src-awk:before { content: 'Awk'; }
  59. pre.src-authinfo::before { content: 'Authinfo'; }
  60. pre.src-C:before { content: 'C'; }
  61. /* pre.src-C++ doesn't work in CSS */
  62. pre.src-clojure:before { content: 'Clojure'; }
  63. pre.src-css:before { content: 'CSS'; }
  64. pre.src-D:before { content: 'D'; }
  65. pre.src-ditaa:before { content: 'ditaa'; }
  66. pre.src-dot:before { content: 'Graphviz'; }
  67. pre.src-calc:before { content: 'Emacs Calc'; }
  68. pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
  69. pre.src-fortran:before { content: 'Fortran'; }
  70. pre.src-gnuplot:before { content: 'gnuplot'; }
  71. pre.src-haskell:before { content: 'Haskell'; }
  72. pre.src-hledger:before { content: 'hledger'; }
  73. pre.src-java:before { content: 'Java'; }
  74. pre.src-js:before { content: 'Javascript'; }
  75. pre.src-latex:before { content: 'LaTeX'; }
  76. pre.src-ledger:before { content: 'Ledger'; }
  77. pre.src-lisp:before { content: 'Lisp'; }
  78. pre.src-lilypond:before { content: 'Lilypond'; }
  79. pre.src-lua:before { content: 'Lua'; }
  80. pre.src-matlab:before { content: 'MATLAB'; }
  81. pre.src-mscgen:before { content: 'Mscgen'; }
  82. pre.src-ocaml:before { content: 'Objective Caml'; }
  83. pre.src-octave:before { content: 'Octave'; }
  84. pre.src-org:before { content: 'Org mode'; }
  85. pre.src-oz:before { content: 'OZ'; }
  86. pre.src-plantuml:before { content: 'Plantuml'; }
  87. pre.src-processing:before { content: 'Processing.js'; }
  88. pre.src-python:before { content: 'Python'; }
  89. pre.src-R:before { content: 'R'; }
  90. pre.src-ruby:before { content: 'Ruby'; }
  91. pre.src-sass:before { content: 'Sass'; }
  92. pre.src-scheme:before { content: 'Scheme'; }
  93. pre.src-screen:before { content: 'Gnu Screen'; }
  94. pre.src-sed:before { content: 'Sed'; }
  95. pre.src-sh:before { content: 'shell'; }
  96. pre.src-sql:before { content: 'SQL'; }
  97. pre.src-sqlite:before { content: 'SQLite'; }
  98. /* additional languages in org.el's org-babel-load-languages alist */
  99. pre.src-forth:before { content: 'Forth'; }
  100. pre.src-io:before { content: 'IO'; }
  101. pre.src-J:before { content: 'J'; }
  102. pre.src-makefile:before { content: 'Makefile'; }
  103. pre.src-maxima:before { content: 'Maxima'; }
  104. pre.src-perl:before { content: 'Perl'; }
  105. pre.src-picolisp:before { content: 'Pico Lisp'; }
  106. pre.src-scala:before { content: 'Scala'; }
  107. pre.src-shell:before { content: 'Shell Script'; }
  108. pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
  109. /* additional language identifiers per "defun org-babel-execute"
  110. in ob-*.el */
  111. pre.src-cpp:before { content: 'C++'; }
  112. pre.src-abc:before { content: 'ABC'; }
  113. pre.src-coq:before { content: 'Coq'; }
  114. pre.src-groovy:before { content: 'Groovy'; }
  115. /* additional language identifiers from org-babel-shell-names in
  116. ob-shell.el: ob-shell is the only babel language using a lambda to put
  117. the execution function name together. */
  118. pre.src-bash:before { content: 'bash'; }
  119. pre.src-csh:before { content: 'csh'; }
  120. pre.src-ash:before { content: 'ash'; }
  121. pre.src-dash:before { content: 'dash'; }
  122. pre.src-ksh:before { content: 'ksh'; }
  123. pre.src-mksh:before { content: 'mksh'; }
  124. pre.src-posh:before { content: 'posh'; }
  125. /* Additional Emacs modes also supported by the LaTeX listings package */
  126. pre.src-ada:before { content: 'Ada'; }
  127. pre.src-asm:before { content: 'Assembler'; }
  128. pre.src-caml:before { content: 'Caml'; }
  129. pre.src-delphi:before { content: 'Delphi'; }
  130. pre.src-html:before { content: 'HTML'; }
  131. pre.src-idl:before { content: 'IDL'; }
  132. pre.src-mercury:before { content: 'Mercury'; }
  133. pre.src-metapost:before { content: 'MetaPost'; }
  134. pre.src-modula-2:before { content: 'Modula-2'; }
  135. pre.src-pascal:before { content: 'Pascal'; }
  136. pre.src-ps:before { content: 'PostScript'; }
  137. pre.src-prolog:before { content: 'Prolog'; }
  138. pre.src-simula:before { content: 'Simula'; }
  139. pre.src-tcl:before { content: 'tcl'; }
  140. pre.src-tex:before { content: 'TeX'; }
  141. pre.src-plain-tex:before { content: 'Plain TeX'; }
  142. pre.src-verilog:before { content: 'Verilog'; }
  143. pre.src-vhdl:before { content: 'VHDL'; }
  144. pre.src-xml:before { content: 'XML'; }
  145. pre.src-nxml:before { content: 'XML'; }
  146. /* add a generic configuration mode; LaTeX export needs an additional
  147. (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
  148. pre.src-conf:before { content: 'Configuration File'; }
  149. table { border-collapse:collapse; }
  150. caption.t-above { caption-side: top; }
  151. caption.t-bottom { caption-side: bottom; }
  152. td, th { vertical-align:top; }
  153. th.org-right { text-align: center; }
  154. th.org-left { text-align: center; }
  155. th.org-center { text-align: center; }
  156. td.org-right { text-align: right; }
  157. td.org-left { text-align: left; }
  158. td.org-center { text-align: center; }
  159. dt { font-weight: bold; }
  160. .footpara { display: inline; }
  161. .footdef { margin-bottom: 1em; }
  162. .figure { padding: 1em; }
  163. .figure p { text-align: center; }
  164. .equation-container {
  165. display: table;
  166. text-align: center;
  167. width: 100%;
  168. }
  169. .equation {
  170. vertical-align: middle;
  171. }
  172. .equation-label {
  173. display: table-cell;
  174. text-align: right;
  175. vertical-align: middle;
  176. }
  177. .inlinetask {
  178. padding: 10px;
  179. border: 2px solid gray;
  180. margin: 10px;
  181. background: #ffffcc;
  182. }
  183. #org-div-home-and-up
  184. { text-align: right; font-size: 70%; white-space: nowrap; }
  185. textarea { overflow-x: auto; }
  186. .linenr { font-size: smaller }
  187. .code-highlighted { background-color: #ffff00; }
  188. .org-info-js_info-navigation { border-style: none; }
  189. #org-info-js_console-label
  190. { font-size: 10px; font-weight: bold; white-space: nowrap; }
  191. .org-info-js_search-highlight
  192. { background-color: #ffff00; color: #000000; font-weight: bold; }
  193. .org-svg { }
  194. </style>
  195. </head>
  196. <body>
  197. <div id="content" class="content">
  198. <h1 class="title">Lab8 Solution Amirlan Sharipov (BS21-CS-01)</h1>
  199. <div id="table-of-contents" role="doc-toc">
  200. <h2>Table of Contents</h2>
  201. <div id="text-table-of-contents" role="doc-toc">
  202. <ul>
  203. <li><a href="#org0007992">1. Question 1</a></li>
  204. <li><a href="#orga4022cb">2. Question 2</a>
  205. <ul>
  206. <li><a href="#orgaa7681b">2.1. Information taken from man pages:</a>
  207. <ul>
  208. <li><a href="#org3d62e77">2.1.1. basic.target</a></li>
  209. <li><a href="#org2c7a54d">2.1.2. graphical.target</a></li>
  210. <li><a href="#orgaa0ad68">2.1.3. multi-user.target</a></li>
  211. <li><a href="#org088723a">2.1.4. sysinit.target</a></li>
  212. </ul>
  213. </li>
  214. <li><a href="#org28d8cd5">2.2. Wants for sysinit.target</a></li>
  215. </ul>
  216. </li>
  217. <li><a href="#org6fe32f2">3. Question 3</a></li>
  218. <li><a href="#org198189e">4. Question 4</a></li>
  219. </ul>
  220. </div>
  221. </div>
  222. <div id="outline-container-org0007992" class="outline-2">
  223. <h2 id="org0007992"><span class="section-number-2">1.</span> Question 1</h2>
  224. <div class="outline-text-2" id="text-1">
  225. <div class="org-src-container">
  226. <pre class="src src-bash">systemd-analyze
  227. systemd-analyze plot &gt; systemd.svg
  228. </pre>
  229. </div>
  230. <pre class="example">
  231. Startup finished in 5.093s (firmware) + 122ms (loader) + 7.459s (kernel) + 4.545s (userspace) = 17.221s
  232. graphical.target reached after 4.544s in userspace.
  233. </pre>
  234. <div id="orgcc0476f" class="figure">
  235. <p><img src="./systemd.svg" alt="systemd.svg" class="org-svg" width="1000px" />
  236. </p>
  237. </div>
  238. </div>
  239. </div>
  240. <div id="outline-container-orga4022cb" class="outline-2">
  241. <h2 id="orga4022cb"><span class="section-number-2">2.</span> Question 2</h2>
  242. <div class="outline-text-2" id="text-2">
  243. <p>
  244. graphical.target -&gt; multi-user.target -&gt; basic.target -&gt; sysinit.target
  245. </p>
  246. <div class="org-src-container">
  247. <pre class="src src-bash"><span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/graphical.target
  248. <span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/multi-user.target
  249. <span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/basic.target
  250. <span style="color: #c792ea;">cat</span> /usr/lib/systemd/system/sysinit.target
  251. </pre>
  252. </div>
  253. <pre class="example" id="org05984f4">
  254. # SPDX-License-Identifier: LGPL-2.1-or-later
  255. #
  256. # This file is part of systemd.
  257. #
  258. # systemd is free software; you can redistribute it and/or modify it
  259. # under the terms of the GNU Lesser General Public License as published by
  260. # the Free Software Foundation; either version 2.1 of the License, or
  261. # (at your option) any later version.
  262. [Unit]
  263. Description=Graphical Interface
  264. Documentation=man:systemd.special(7)
  265. Requires=multi-user.target
  266. Wants=display-manager.service
  267. Conflicts=rescue.service rescue.target
  268. After=multi-user.target rescue.service rescue.target display-manager.service
  269. AllowIsolate=yes
  270. # SPDX-License-Identifier: LGPL-2.1-or-later
  271. #
  272. # This file is part of systemd.
  273. #
  274. # systemd is free software; you can redistribute it and/or modify it
  275. # under the terms of the GNU Lesser General Public License as published by
  276. # the Free Software Foundation; either version 2.1 of the License, or
  277. # (at your option) any later version.
  278. [Unit]
  279. Description=Multi-User System
  280. Documentation=man:systemd.special(7)
  281. Requires=basic.target
  282. Conflicts=rescue.service rescue.target
  283. After=basic.target rescue.service rescue.target
  284. AllowIsolate=yes
  285. # SPDX-License-Identifier: LGPL-2.1-or-later
  286. #
  287. # This file is part of systemd.
  288. #
  289. # systemd is free software; you can redistribute it and/or modify it
  290. # under the terms of the GNU Lesser General Public License as published by
  291. # the Free Software Foundation; either version 2.1 of the License, or
  292. # (at your option) any later version.
  293. [Unit]
  294. Description=Basic System
  295. Documentation=man:systemd.special(7)
  296. Requires=sysinit.target
  297. Wants=sockets.target timers.target paths.target slices.target
  298. After=sysinit.target sockets.target paths.target slices.target tmp.mount
  299. # We support /var, /tmp, /var/tmp, being on NFS, but we don't pull in
  300. # remote-fs.target by default, hence pull them in explicitly here. Note that we
  301. # require /var and /var/tmp, but only add a Wants= type dependency on /tmp, as
  302. # we support that unit being masked, and this should not be considered an error.
  303. RequiresMountsFor=/var /var/tmp
  304. Wants=tmp.mount
  305. # SPDX-License-Identifier: LGPL-2.1-or-later
  306. #
  307. # This file is part of systemd.
  308. #
  309. # systemd is free software; you can redistribute it and/or modify it
  310. # under the terms of the GNU Lesser General Public License as published by
  311. # the Free Software Foundation; either version 2.1 of the License, or
  312. # (at your option) any later version.
  313. [Unit]
  314. Description=System Initialization
  315. Documentation=man:systemd.special(7)
  316. Wants=local-fs.target swap.target
  317. After=local-fs.target swap.target
  318. Conflicts=emergency.service emergency.target
  319. Before=emergency.service emergency.target
  320. </pre>
  321. </div>
  322. <div id="outline-container-orgaa7681b" class="outline-3">
  323. <h3 id="orgaa7681b"><span class="section-number-3">2.1.</span> Information taken from man pages:</h3>
  324. <div class="outline-text-3" id="text-2-1">
  325. </div>
  326. <div id="outline-container-org3d62e77" class="outline-4">
  327. <h4 id="org3d62e77"><span class="section-number-4">2.1.1.</span> basic.target</h4>
  328. <div class="outline-text-4" id="text-2-1-1">
  329. <p>
  330. A special target unit covering basic boot-up.
  331. </p>
  332. </div>
  333. </div>
  334. <div id="outline-container-org2c7a54d" class="outline-4">
  335. <h4 id="org2c7a54d"><span class="section-number-4">2.1.2.</span> graphical.target</h4>
  336. <div class="outline-text-4" id="text-2-1-2">
  337. <p>
  338. A special target unit for setting up a graphical login screen. This pulls in multi-user.target.
  339. </p>
  340. </div>
  341. </div>
  342. <div id="outline-container-orgaa0ad68" class="outline-4">
  343. <h4 id="orgaa0ad68"><span class="section-number-4">2.1.3.</span> multi-user.target</h4>
  344. <div class="outline-text-4" id="text-2-1-3">
  345. <p>
  346. A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical.target.
  347. </p>
  348. </div>
  349. </div>
  350. <div id="outline-container-org088723a" class="outline-4">
  351. <h4 id="org088723a"><span class="section-number-4">2.1.4.</span> sysinit.target</h4>
  352. <div class="outline-text-4" id="text-2-1-4">
  353. <p>
  354. This target pulls in the services required for system initialization.
  355. </p>
  356. </div>
  357. </div>
  358. </div>
  359. <div id="outline-container-org28d8cd5" class="outline-3">
  360. <h3 id="org28d8cd5"><span class="section-number-3">2.2.</span> Wants for sysinit.target</h3>
  361. <div class="outline-text-3" id="text-2-2">
  362. <p>
  363. Wants=local-fs.target swap.target
  364. Wants is used like Requires, but it&rsquo;s less strict, meaning that it can start if the &ldquo;wanted&rdquo; service doesn&rsquo;t exist or failed to start.
  365. In this case, it wants local filesystems and swap to start.
  366. </p>
  367. </div>
  368. </div>
  369. </div>
  370. <div id="outline-container-org6fe32f2" class="outline-2">
  371. <h2 id="org6fe32f2"><span class="section-number-2">3.</span> Question 3</h2>
  372. <div class="outline-text-2" id="text-3">
  373. <div class="org-src-container">
  374. <pre class="src src-bash"><span style="color: #c792ea;">cat</span> webserver.sh
  375. </pre>
  376. </div>
  377. <pre class="example">
  378. #!/bin/bash
  379. while true ; do
  380. STATS="&lt;h1&gt;Uptime&lt;/h1&gt;$(uptime)\n&lt;h1&gt;Inode and disk usage&lt;/h1&gt;$(df -ih)\n&lt;h1&gt;Mem usage&lt;/h1&gt;$(free -h)\n&lt;h1&gt;Syslog&lt;/h1&gt;$(tail -n 15 /var/log/syslog)\r\n\r\n"
  381. LEN=$(printf "%s" "$STATS" | wc -c)
  382. RES="HTTP/1.1 200OK\r\nContent-Length: $LEN\r\n\r\n"
  383. echo -e "$RES$STATS"| nc -l -p 1500;
  384. done
  385. </pre>
  386. <p>
  387. [Unit]
  388. Description=stats web server
  389. </p>
  390. <p>
  391. [Service]
  392. User=root
  393. ExecStart=/home/rinri/edu/sna/webserver.sh
  394. Restart=always
  395. CPUQuota=15%
  396. MemoryMax=256000000
  397. </p>
  398. <p>
  399. [Install]
  400. WantedBy=multi-user.target
  401. </p>
  402. </div>
  403. </div>
  404. <div id="outline-container-org198189e" class="outline-2">
  405. <h2 id="org198189e"><span class="section-number-2">4.</span> Question 4</h2>
  406. <div class="outline-text-2" id="text-4">
  407. <div class="org-src-container">
  408. <pre class="src src-bash"><span style="color: #c792ea;">cat</span> update.sh
  409. </pre>
  410. </div>
  411. <pre class="example">
  412. #!/bin/bash
  413. pacman -Sy
  414. </pre>
  415. <p>
  416. [Unit]
  417. Description=update package sources list
  418. </p>
  419. <p>
  420. [Service]
  421. User=root
  422. ExecStart=/home/rinri/edu/sna/update.sh
  423. </p>
  424. <p>
  425. [Install]
  426. WantedBy=multi-user.target
  427. </p>
  428. </div>
  429. </div>
  430. </div>
  431. <div id="postamble" class="status">
  432. <p class="author">Author: Amirlan Sharipov (BS21-CS-01)</p>
  433. <p class="date">Created: 2023-03-23 Thu 23:57</p>
  434. </div>
  435. </body>
  436. </html>