l1a_prep 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd399c44491027e64319d2a8cbdde4d4353bd41b1f7d271fbdeead7fa4d77112
4
- data.tar.gz: b9ee44786c667ed4da9dc3f7483787171963fae0c9be14f712a41975c12982b9
3
+ metadata.gz: 8d6940c70dea5c0f4733957eaa1a9b85ffd77424b71828537c2da8223f031185
4
+ data.tar.gz: b0b219fc7c6200401b796e57ae39cc91f52c85eb8a52de1da3c9d20c297bbd3d
5
5
  SHA512:
6
- metadata.gz: a6e3d4044a2724c91c9c62d49995db425e99a9087b8dbf54bc9dd4334de067e45e12e8e9e7c6d34ba5cc705758949d394ab75e135f7b0c2efdb33d89251cf722
7
- data.tar.gz: 40a57042e602b6251b6e29ecf7fb6f6f654e912efed87f705ec41ce15b5e3eb66e064c312a9f0287c12a5e200a87a3aba398fde03272ebe278eac152389325a4
6
+ metadata.gz: 871af127cd5e5a74c941c81298e3ec522f1f164b55aafcea6ff8de052e3542a4ff7886b642d7cf9cb83075785f96cf4df04bbe469ca52585245753d134f9df26
7
+ data.tar.gz: a262af5a99394ee5ae8f34a3f47327610f4134bd885203e2a2f8cc60ce289175b41c5173be4786ee5eca7440c5b6a4694e1407e6f6c29f967fc97c68feb2d831
data/.DS_Store CHANGED
Binary file
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ l1a_prep (1.0.0)
5
+ colorize (>= 0.8.0)
6
+ tty-prompt (>= 0.22.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ colorize (0.8.1)
13
+ diff-lcs (1.4.4)
14
+ parallel (1.20.1)
15
+ parser (3.0.0.0)
16
+ ast (~> 2.4.1)
17
+ pastel (0.8.0)
18
+ tty-color (~> 0.5)
19
+ rainbow (3.0.0)
20
+ rake (13.0.3)
21
+ regexp_parser (2.1.1)
22
+ rexml (3.2.5)
23
+ rspec (3.10.0)
24
+ rspec-core (~> 3.10.0)
25
+ rspec-expectations (~> 3.10.0)
26
+ rspec-mocks (~> 3.10.0)
27
+ rspec-core (3.10.1)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-expectations (3.10.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.10.0)
32
+ rspec-mocks (3.10.2)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.10.0)
35
+ rspec-support (3.10.2)
36
+ rubocop (1.12.1)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.0.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml
42
+ rubocop-ast (>= 1.2.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 3.0)
45
+ rubocop-ast (1.4.1)
46
+ parser (>= 2.7.1.5)
47
+ ruby-progressbar (1.11.0)
48
+ tty-color (0.6.0)
49
+ tty-cursor (0.7.1)
50
+ tty-prompt (0.23.0)
51
+ pastel (~> 0.8)
52
+ tty-reader (~> 0.8)
53
+ tty-reader (0.9.0)
54
+ tty-cursor (~> 0.7)
55
+ tty-screen (~> 0.8)
56
+ wisper (~> 2.0)
57
+ tty-screen (0.8.1)
58
+ unicode-display_width (2.0.0)
59
+ wisper (2.0.1)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ l1a_prep!
66
+ rake (~> 13.0)
67
+ rspec (~> 3.0)
68
+ rubocop (~> 1.7)
69
+
70
+ BUNDLED WITH
71
+ 1.17.2
Binary file
data/l1a_prep.gemspec CHANGED
@@ -30,7 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
- # spec.add_dependency "example-gem", "~> 1.0"
33
+ spec.add_dependency "tty-prompt", ">= 0.22.0"
34
+ spec.add_dependency "colorize", ">= 0.8.0"
34
35
 
35
36
  # For more information and examples about making a new gem, checkout our
36
37
  # guide at: https://bundler.io/guides/creating_gem.html
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,169 @@
1
+ #!/bin/bash
2
+
3
+ rows=$(tput lines)
4
+ cols=$(tput cols)
5
+ colors=(red green blue purple cyan yellow brown)
6
+ lock_file=
7
+ lock_file_base=/tmp/$(basename $0 .sh)
8
+
9
+ multiple=0
10
+ if [[ "$1" ]]; then
11
+ nsingle=$1
12
+ shift
13
+ else
14
+ nsingle=10
15
+ fi
16
+ if [[ "$1" ]]; then
17
+ nmultiple=$1
18
+ shift
19
+ if [[ $nmultiple -gt 8 ]]; then nmultiple=8; fi
20
+ else
21
+ nmultiple=6
22
+ fi
23
+
24
+
25
+ function colorstr()
26
+ {
27
+ local row=$1
28
+ local col=$2
29
+ local color=$3
30
+ local v
31
+ case "$color" in
32
+ red) v=31;;
33
+ green) v=34;;
34
+ blue) v=32;;
35
+ purple) v=35;;
36
+ cyan) v=36;;
37
+ yellow) v=33;;
38
+ brown) v=33;;
39
+ white) v=37;;
40
+ *) v=;;
41
+ esac
42
+ shift 3
43
+
44
+ if [[ $multiple -ne 0 ]]; then
45
+ touch $lock_file
46
+ while [[ $(ls $lock_file_base.* 2>/dev/null | head -n 1) != $lock_file ]]
47
+ do
48
+ sleep 0.05
49
+ done
50
+ fi
51
+
52
+ tput cup $row $col
53
+ echo -n -e "\e["$v"m"
54
+ set -f
55
+ echo -n $*
56
+ set +f
57
+ if [[ $multiple -ne 0 ]]; then
58
+ rm -f $lock_file
59
+ fi
60
+ }
61
+
62
+ function center_colorstr()
63
+ {
64
+ local row=$1
65
+ local color=$2
66
+ shift 2
67
+ local s="$*"
68
+ local slen=${#s}
69
+ colorstr $row $(((cols / 2) - (slen / 2))) $color "$s"
70
+ }
71
+
72
+ function fireworks()
73
+ {
74
+ local row=$((rows - 1))
75
+ local col=$(((RANDOM % (cols / 2)) + (cols / 4)))
76
+ local height=$((RANDOM % rows - 2))
77
+ local slant
78
+ local h
79
+ local color1=${colors[$((RANDOM % ${#colors[*]}))]}
80
+ local color2=${colors[$((RANDOM % ${#colors[*]}))]}
81
+ local color3=${colors[$((RANDOM % ${#colors[*]}))]}
82
+ while [[ $color1 == $color2 || $color1 == $color3 || $color2 == $color3 ]]
83
+ do
84
+ color2=${colors[$((RANDOM % ${#colors[*]}))]}
85
+ color3=${colors[$((RANDOM % ${#colors[*]}))]}
86
+ done
87
+
88
+ case $((RANDOM % 4)) in
89
+ 0) slant=-2;;
90
+ 1) slant=-1;;
91
+ 2) slant=1;;
92
+ 3) slant=2;;
93
+ esac
94
+
95
+ if [[ $height -gt 5 ]]; then
96
+ h=$height
97
+
98
+ while [[ $h -gt 0 ]]
99
+ do
100
+ colorstr $row $col $color1 '.'
101
+ let row--
102
+ if [[ $((col + slant)) -ge $((cols - 3)) || $((col + slant)) -le 2 ]]; then break; fi
103
+ let col+=slant
104
+ let h--
105
+ sleep 0.1
106
+ done
107
+
108
+ if [[ $((col + slant)) -lt $((cols - 3)) && $((col + slant)) -gt 2 ]]; then
109
+
110
+ h=$((height / 5))
111
+
112
+ while [[ $h -gt 0 ]]
113
+ do
114
+ colorstr $row $col $color2 '.'
115
+ let row++
116
+ if [[ $((col + slant)) -ge $((cols - 3)) || $((col + slant)) -le 2 ]]; then break; fi
117
+ let col+=slant
118
+ let h--
119
+ sleep 0.1
120
+ done
121
+ fi
122
+
123
+ colorstr $((row)) $((col - 1)) $color3 '***'
124
+ colorstr $((row - 1)) $((col)) $color3 '*'
125
+ colorstr $((row + 1)) $((col)) $color3 '*'
126
+ fi
127
+ }
128
+
129
+ for i in $(seq 1 $nsingle)
130
+ do
131
+ clear
132
+ fireworks
133
+ sleep 1
134
+ done
135
+
136
+ clear
137
+
138
+ pids=
139
+ for i in $(seq 1 $nmultiple)
140
+ do
141
+ let multiple++
142
+ lock_file=$lock_file_base.$i
143
+ fireworks &
144
+ pids="$pids $!"
145
+ done
146
+
147
+ trap "kill -9 $pids 2>/dev/null" EXIT
148
+
149
+ wait $pids
150
+ sleep 3
151
+
152
+ clear
153
+
154
+ echo ''
155
+ echo ''
156
+ echo ''
157
+ echo ''
158
+ echo -e "\t Where there's focus, there is progress!"
159
+ echo ''
160
+ echo -e "\t Go crush the L1A!"
161
+ echo ''
162
+ echo -e "\t WP Engine ... LFG!"
163
+
164
+ sleep 5
165
+ clear
166
+
167
+
168
+ # vim: tabstop=4: shiftwidth=4: noexpandtab:
169
+ # kate: tab-width 4; indent-width 4; replace-tabs false;
@@ -1,664 +1,672 @@
1
- class L1aPrep
2
-
3
- require 'tty-prompt'
4
- require 'colorize'
5
-
6
- # prints the WP Engine text in CLI screen
7
-
8
- def self.logo
9
-
10
- puts "
11
-
12
- 888 8888888888b. 8888888888 d8b
13
- 888 o 888888 Y88b 888 Y8P
14
- 888 d8b 888888 888 888
15
- 888 d888b 888888 d88P 8888888 88888b. .d88b. 88888888b. .d88b.
16
- 888d88888b8888888888P 888 888 88bd88P 88b888888 8bd8P Y8b
17
- 88888P Y88888888 888 888 888888 888888888 88888888888
18
- 8888P Y8888888 888 888 888Y88b 888888888 888Y8b.
19
- 888P Y888888 8888888888888 888 Y88888888888 888 Y8888
20
- 888
21
- Y8b d88P
22
- Y88P
23
- ".green
24
- puts "
25
- ** Pass the L1A Assessment **
26
- ".green
27
- end
28
-
29
- self.logo
30
-
31
-
32
- def self.questions
33
-
34
- # score
35
-
36
- @num_of_q = 0
37
- @correct = 0
38
-
39
- # question 1
40
-
41
- prompt = TTY::Prompt.new
42
- question = 'The primary migration process you will use as an L1a'
43
- choices = %w(magic reparent internal geo-targeted)
44
- answer = prompt.select(question, choices)
45
- if answer == "magic"
46
- puts ''
47
- puts ' >> Correct! Magic Migrations are set in overdrive'
48
- puts ''
49
- @num_of_q += 1
50
- @correct += 1
51
- else
52
- puts ''
53
- puts ' >> Not quite... moving right along!'
54
- puts ''
55
- @num_of_q += 1
56
- @correct = @correct
57
- end
58
-
59
- puts " #{@correct} out of #{@num_of_q} questions correct".red
60
- puts ''
61
-
62
- # question 2
63
-
64
- prompt = TTY::Prompt.new
65
-
66
- answer = prompt.select('What is a M2p Migration?') do |menu|
67
-
68
- menu.choice 'Member to Peer'
69
- menu.choice 'Member to Platform'
70
- menu.choice 'Move to preferred'
71
- menu.choice 'Move to Peer'
72
- end
73
-
74
- if answer == "Move to preferred"
75
- puts ''
76
- puts ' >> Correct! Manual migration that can be done from the terminal (only to be used if the magic functionality is not available)'
77
- puts ''
78
- @num_of_q += 1
79
- @correct += 1
80
- else
81
- puts ''
82
- puts ' >> Not quite... moving right along!'
83
- puts ''
84
- @num_of_q += 1
85
- @correct = @correct
86
- end
87
-
88
- puts " #{@correct} out of #{@num_of_q} questions correct".red
89
- puts ''
90
-
91
- # question 3
92
-
93
- prompt = TTY::Prompt.new
94
- answer = prompt.ask('File location of the Nginx access log? ... use >> install. << as the site name')
95
-
96
- if answer == "/var/log/nginx/install.access.log"
97
- puts ''
98
- puts ' >> Correct!'
99
- puts ''
100
- @num_of_q += 1
101
- @correct += 1
102
- else
103
- puts ''
104
- puts ' >> Not quite... /var/log/nginx/install.access.log'
105
- puts ''
106
- @num_of_q += 1
107
- @correct = @correct
108
- end
109
-
110
- puts " #{@correct} out of #{@num_of_q} questions correct".red
111
- puts ''
112
-
113
- # question 4
114
-
115
- prompt = TTY::Prompt.new
116
- answer = prompt.ask('File location of the apachestyle Nginx access log? ... use >> install. << as the site name')
117
-
118
- if answer == "/var/log/nginx/install.apachestyle.log"
119
- puts ''
120
- puts ' >> Correct! Note that the apachestyle logs are the Nginx logs, but keep the same formatting of the Apache logs'
121
- puts ''
122
- @num_of_q += 1
123
- @correct += 1
124
- else
125
- puts ''
126
- puts ' >> Not quite... /var/log/nginx/install.apachestyle.log'
127
- puts ''
128
- @num_of_q += 1
129
- @correct = @correct
130
- end
131
-
132
- puts " #{@correct} out of #{@num_of_q} questions correct".red
133
- puts ''
134
-
135
- # question 5
136
-
137
- prompt = TTY::Prompt.new
138
- answer = prompt.ask('Log location of the processes killed by apache?')
139
-
140
- if answer == "/var/log/apache-killed-by-wpe.log"
141
- puts ''
142
- puts ' >> Correct!'
143
- puts ''
144
- @num_of_q += 1
145
- @correct += 1
146
- else
147
- puts ''
148
- puts ' >> Not quite... /var/log/apache-killed-by-wpe.log'
149
- puts ''
150
- @num_of_q += 1
151
- @correct = @correct
152
- end
153
-
154
- puts " #{@correct} out of #{@num_of_q} questions correct".red
155
- puts ''
156
-
157
- # question 6
158
-
159
- prompt = TTY::Prompt.new
160
- answer = prompt.ask('File location of the apache access log? ... use >> install. << as the site name')
161
-
162
- if answer == "/var/log/apache2/install.access.log"
163
- puts ''
164
- puts ' >> Correct!'
165
- puts ''
166
- @num_of_q += 1
167
- @correct += 1
168
- else
169
- puts ''
170
- puts ' >> Not quite... /var/log/apache2/install.access.log'
171
- puts ''
172
- @num_of_q += 1
173
- @correct = @correct
174
- end
175
-
176
- puts " #{@correct} out of #{@num_of_q} questions correct".red
177
- puts ''
178
-
179
- # question 7
180
-
181
- prompt = TTY::Prompt.new
182
- answer = prompt.ask('File location of the apache error log? ... use >> install. as the site name')
183
-
184
- if answer == "/var/log/apache2/install.error.log"
185
- puts ''
186
- puts ' >> Correct!'
187
- puts ''
188
- @num_of_q += 1
189
- @correct += 1
190
- else
191
- puts ''
192
- puts ' >> Not quite... /var/log/apache2/install.error.log'
193
- puts ''
194
- @num_of_q += 1
195
- @correct = @correct
196
- end
197
-
198
- puts " #{@correct} out of #{@num_of_q} questions correct".red
199
- puts ''
200
-
201
- # question 8
202
-
203
- prompt = TTY::Prompt.new
204
- answer = prompt.select('$time_local|v1|$remote_addr|$http_host|$status|$body_bytes_sent|$upst ream_addr|$upstream_response_time|$request_time|$request|$is_logge d_as_bot|$is_prefetch|$http_cf_ray') do |menu|
205
- menu.choice 'Apache log'
206
- menu.choice 'Nginx log'
207
- end
208
-
209
- if answer == "Nginx log"
210
- puts ''
211
- puts ' >> Correct!'
212
- puts ''
213
- @num_of_q += 1
214
- @correct += 1
215
- else
216
- puts ''
217
- puts ' >> Not quite... this is a Nginx log'
218
- puts ''
219
- @num_of_q += 1
220
- @correct = @correct
221
- end
222
-
223
- puts " #{@correct} out of #{@num_of_q} questions correct".red
224
- puts ''
225
-
226
- # question 9
227
-
228
- prompt = TTY::Prompt.new
229
-
230
- answer = prompt.select('$remote_addr $http_host $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $wpe_user_agent') do |menu|
231
- menu.choice 'Apache log'
232
- menu.choice 'Nginx log'
233
- end
234
-
235
- if answer == "Apache log"
236
- puts ''
237
- puts ' >> Correct!'
238
- puts ''
239
- @num_of_q += 1
240
- @correct += 1
241
- else
242
- puts ''
243
- puts ' >> Not quite... this is a Apache log'
244
- puts ''
245
- @num_of_q += 1
246
- @correct = @correct
247
- end
248
-
249
- puts " #{@correct} out of #{@num_of_q} questions correct".red
250
- puts ''
251
-
252
- # question 10
253
-
254
- prompt = TTY::Prompt.new
255
- answer = prompt.ask('Linux command to output the first 10 lines of the file called wpengine.txt')
256
-
257
- if answer == "head wpengine.txt"
258
- puts ''
259
- puts ' >> Correct!'
260
- puts ''
261
- @num_of_q += 1
262
- @correct += 1
263
- else
264
- puts ''
265
- puts ' >> Not quite... head wpengine.txt'
266
- puts ''
267
- @num_of_q += 1
268
- @correct = @correct
269
- end
270
-
271
- puts " #{@correct} out of #{@num_of_q} questions correct".red
272
- puts ''
273
-
274
- # question 11
275
-
276
- prompt = TTY::Prompt.new
277
- answer = prompt.ask('Linux command to output the last 10 lines of wpengine.txt')
278
-
279
- if answer == "tail wpengine.txt"
280
- puts ''
281
- puts ' >> Correct!'
282
- puts ''
283
- @num_of_q += 1
284
- @correct += 1
285
- else
286
- puts ''
287
- puts ' >> Not quite... tail wpengine.txt'
288
- puts ''
289
- @num_of_q += 1
290
- @correct = @correct
291
- end
292
-
293
- puts " #{@correct} out of #{@num_of_q} questions correct".red
294
- puts ''
295
-
296
- # question 12
297
-
298
- prompt = TTY::Prompt.new
299
- answer = prompt.ask('Linux command to show directory space usage in KB/MB/GB')
300
-
301
- if answer == "du -sh *"
302
- puts ''
303
- puts ' >> Correct!'
304
- puts ''
305
- @num_of_q += 1
306
- @correct += 1
307
- else
308
- puts ''
309
- puts ' >> Not quite... du -sh *'
310
- puts ''
311
- @num_of_q += 1
312
- @correct = @correct
313
- end
314
-
315
- puts " #{@correct} out of #{@num_of_q} questions correct".red
316
- puts ''
317
-
318
- # question 11
319
-
320
- prompt = TTY::Prompt.new
321
- answer = prompt.ask('Linux command to show disk usage... mainly for the cluster, shows the % at which the server is loading memory')
322
-
323
- if answer == "df -h"
324
- puts ''
325
- puts ' >> Correct!'
326
- puts ''
327
- @num_of_q += 1
328
- @correct += 1
329
- else
330
- puts ''
331
- puts ' >> Not quite... df -h'
332
- puts ''
333
- @num_of_q += 1
334
- @correct = @correct
335
- end
336
-
337
- puts " #{@correct} out of #{@num_of_q} questions correct".red
338
- puts ''
339
-
340
-
341
- # question 12
342
-
343
- prompt = TTY::Prompt.new
344
- answer = prompt.ask('Linux command to show how much CPU % and Memory % is being used and which processes are using them the most')
345
-
346
- if answer == "htop"
347
- puts ''
348
- puts ' >> Correct!'
349
- puts ''
350
- @num_of_q += 1
351
- @correct += 1
352
- else
353
- puts ''
354
- puts ' >> Not quite... htop'
355
- puts ''
356
- @num_of_q += 1
357
- @correct = @correct
358
- end
359
-
360
- puts " #{@correct} out of #{@num_of_q} questions correct".red
361
- puts ''
362
-
363
- # question 13
364
-
365
- prompt = TTY::Prompt.new
366
- answer = prompt.ask('Linux command to show the status of the server throughout a specific point in time')
367
-
368
- if answer == "sar -q"
369
- puts ''
370
- puts ' >> Correct!'
371
- puts ''
372
- @num_of_q += 1
373
- @correct += 1
374
- else
375
- puts ''
376
- puts ' >> Not quite... sar -q'
377
- puts ''
378
- @num_of_q += 1
379
- @correct = @correct
380
- end
381
-
382
- puts " #{@correct} out of #{@num_of_q} questions correct".red
383
- puts ''
384
-
385
- # question 14
386
-
387
- prompt = TTY::Prompt.new
388
- answer = prompt.ask('Linux command to show the number of cores currently on the server/cluster')
389
-
390
- if answer == "nproc"
391
- puts ''
392
- puts ' >> Correct!'
393
- puts ''
394
- @num_of_q += 1
395
- @correct += 1
396
- else
397
- puts ''
398
- puts ' >> Not quite... nproc'
399
- puts ''
400
- @num_of_q += 1
401
- @correct = @correct
402
- end
403
-
404
- puts " #{@correct} out of #{@num_of_q} questions correct".red
405
- puts ''
406
-
407
- # question 15
408
-
409
- prompt = TTY::Prompt.new
410
- answer = prompt.ask('Linux command to find the amount of Memory on a current server and how much is being utilized')
411
-
412
- if answer == "free"
413
- puts ''
414
- puts ' >> Correct!'
415
- puts ''
416
- @num_of_q += 1
417
- @correct += 1
418
- else
419
- puts ''
420
- puts ' >> Not quite... free'
421
- puts ''
422
- @num_of_q += 1
423
- @correct = @correct
424
- end
425
-
426
- puts " #{@correct} out of #{@num_of_q} questions correct".red
427
- puts ''
428
-
429
- # question 16
430
-
431
- prompt = TTY::Prompt.new
432
- answer = prompt.ask('Linux command to find the amount of Memory on a current server and how much is being utilized')
433
-
434
- if answer == "free"
435
- puts ''
436
- puts ' >> Correct!'
437
- puts ''
438
- @num_of_q += 1
439
- @correct += 1
440
- else
441
- puts ''
442
- puts ' >> Not quite... free'
443
- puts ''
444
- @num_of_q += 1
445
- @correct = @correct
446
- end
447
-
448
- puts " #{@correct} out of #{@num_of_q} questions correct".red
449
- puts ''
450
-
451
- # question 17
452
-
453
- prompt = TTY::Prompt.new
454
- answer = prompt.ask('Linux command to find all files with extention .git')
455
-
456
- if answer == "find -name \"*.git\""
457
- puts ''
458
- puts ' >> Correct!'
459
- puts ''
460
- @num_of_q += 1
461
- @correct += 1
462
- else
463
- puts ''
464
- puts ' >> Not quite... find -name \"*.git\"'
465
- puts ''
466
- @num_of_q += 1
467
- @correct = @correct
468
- end
469
-
470
- puts " #{@correct} out of #{@num_of_q} questions correct".red
471
- puts ''
472
-
473
- # question 18
474
-
475
- prompt = TTY::Prompt.new
476
-
477
- answer = prompt.select('/nas/config/live/installname/ is a ...') do |menu|
478
- menu.choice 'Absolute Path'
479
- menu.choice 'Relative Path'
480
- end
481
-
482
- if answer == "Absolute Path"
483
- puts ''
484
- puts ' >> Correct! Referring to everything based on the root directory and always starting with a /'
485
- puts ''
486
- @num_of_q += 1
487
- @correct += 1
488
- else
489
- puts ''
490
- puts ' >> Not quite... Absolute Path'
491
- puts ''
492
- @num_of_q += 1
493
- @correct = @correct
494
- end
495
-
496
- puts " #{@correct} out of #{@num_of_q} questions correct".red
497
- puts ''
498
-
499
- # question 19
500
-
501
- prompt = TTY::Prompt.new
502
-
503
- answer = prompt.select('_wpeprivate/ is a ...') do |menu|
504
- menu.choice 'Absolute Path'
505
- menu.choice 'Relative Path'
506
- end
507
-
508
- if answer == "Relative Path"
509
- puts ''
510
- puts ' >> Correct! Command on what you want to operate on relative to where you are. Interacts with current directory.'
511
- puts ''
512
- @num_of_q += 1
513
- @correct += 1
514
- else
515
- puts ''
516
- puts ' >> Not quite... Relative Path'
517
- puts ''
518
- @num_of_q += 1
519
- @correct = @correct
520
- end
521
-
522
- puts " #{@correct} out of #{@num_of_q} questions correct".red
523
- puts ''
524
-
525
- # question 20
526
-
527
- prompt = TTY::Prompt.new
528
- answer = prompt.ask('Cut command to find top ten page requests, requested by googlebot from 10-11 am utc: ... use the \'install\' as the name of the install')
529
-
530
- if answer == "grep \'2020:10\' /var/log/nginx/install.apachestyle.log | grep -i \'googlebot\' | cut -d\'\"\' -f2 | sort | uniq -c | sort -nr | head"
531
- puts ''
532
- puts ' >> Correct!'
533
- puts ''
534
- @num_of_q += 1
535
- @correct += 1
536
- else
537
- puts ''
538
- puts ' >> Not quite... grep \'2020:10\' /var/log/nginx/install.apachestyle.log | grep -i \'googlebot\' | cut -d\'\"\' -f2 | sort | uniq -c | sort -nr | head'
539
- puts ''
540
- @num_of_q += 1
541
- @correct = @correct
542
- end
543
-
544
- puts " #{@correct} out of #{@num_of_q} questions correct".red
545
- puts ''
546
-
547
- # question 21
548
-
549
- prompt = TTY::Prompt.new
550
- answer = prompt.ask('Cut command to find Top Ten IP’s that hit today ... use the \'install\' as the name of the install')
551
-
552
- if answer == "cut -d\" \" -f1 /var/log/nginx/install.apachestyle.log | sort | uniq -c | sort -rn | head"
553
- puts ''
554
- puts ' >> Correct!'
555
- puts ''
556
- @num_of_q += 1
557
- @correct += 1
558
- else
559
- puts ''
560
- puts ' >> Not quite... cut -d\' \' -f1 /var/log/nginx/install.apachestyle.log | sort | uniq -c | sort -rn | head'
561
- puts ''
562
- @num_of_q += 1
563
- @correct = @correct
564
- end
565
-
566
- puts " #{@correct} out of #{@num_of_q} questions correct".red
567
- puts ''
568
-
569
- # question 22
570
-
571
- prompt = TTY::Prompt.new
572
- answer = prompt.ask('Top ten pages that Googlebot hit 2 days ago')
573
-
574
- if answer == "zgrep \"Googlebot\" /var/log/nginx/coinrivet.apachestyle.log.2.gz | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head"
575
- puts ''
576
- puts ' >> Correct!'
577
- puts ''
578
- @num_of_q += 1
579
- @correct += 1
580
- else
581
- puts ''
582
- puts ' >> Not quite... zgrep \"Googlebot\" /var/log/nginx/coinrivet.apachestyle.log.2.gz | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head'
583
- puts ''
584
- @num_of_q += 1
585
- @correct = @correct
586
- end
587
-
588
- puts " #{@correct} out of #{@num_of_q} questions correct".red
589
- puts ''
590
-
591
- # question 23
592
-
593
- prompt = TTY::Prompt.new
594
- answer = prompt.ask('Top ten pages that Googlebot has hit today')
595
-
596
- if answer == "grep \"Googlebot\" /var/log/nginx/coinrivet.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head"
597
- puts ''
598
- puts ' >> Correct!'
599
- puts ''
600
- @num_of_q += 1
601
- @correct += 1
602
- else
603
- puts ''
604
- puts ' >> Not quite... grep \"Googlebot\" /var/log/nginx/coinrivet.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head'
605
- puts ''
606
- @num_of_q += 1
607
- @correct = @correct
608
- end
609
-
610
- puts " #{@correct} out of #{@num_of_q} questions correct".red
611
- puts ''
612
-
613
- # question 24
614
-
615
- prompt = TTY::Prompt.new
616
-
617
- answer = prompt.select('Which type of log will show the user agent?') do |menu|
618
- menu.choice 'Nginx'
619
- menu.choice 'Apachestyle Nginx'
620
- menu.choice 'Apache'
621
- end
622
-
623
- if answer == "Apachestyle Nginx"
624
- puts ''
625
- puts ' >> Correct! Command on what you want to operate on relative to where you are. Interacts with current directory.'
626
- puts ''
627
- @num_of_q += 1
628
- @correct += 1
629
- else
630
- puts ''
631
- puts ' >> Not quite... Apachestyle Nginx'
632
- puts ''
633
- @num_of_q += 1
634
- @correct = @correct
635
- end
636
-
637
- puts " #{@correct} out of #{@num_of_q} questions correct".red
638
- puts ''
639
-
640
- # question 25
641
-
642
- prompt = TTY::Prompt.new
643
- answer = prompt.ask('Top Ten pages that had a 504 response code')
644
-
645
- if answer == "grep \"504\" /var/log/nginx/coinrivet.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head"
646
- puts ''
647
- puts ' >> Correct!'
648
- puts ''
649
- @num_of_q += 1
650
- @correct += 1
651
- else
652
- puts ''
653
- puts ' >> Not quite... grep \"504\" /var/log/nginx/coinrivet.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head'
654
- puts ''
655
- @num_of_q += 1
656
- @correct = @correct
657
- end
658
-
659
- puts " #{@correct} out of #{@num_of_q} questions correct".red
660
- puts ''
661
- end
662
-
663
- self.questions
664
- end
1
+ require 'tty-prompt'
2
+ require 'colorize'
3
+
4
+ class L1aPrep
5
+
6
+ # prints the WP Engine text in CLI screen
7
+
8
+ def self.logo
9
+
10
+ puts "
11
+ 888 8888888888b. 8888888888 d8b
12
+ 888 o 888888 Y88b 888 Y8P
13
+ 888 d8b 888888 888 888
14
+ 888 d888b 888888 d88P 8888888 88888b. .d88b. 88888888b. .d88b.
15
+ 888d88888b8888888888P 888 888 88bd88P 88b888888 8bd8P Y8b
16
+ 88888P Y88888888 888 888 888888 888888888 88888888888
17
+ 8888P Y8888888 888 888 888Y88b 888888888 888Y8b.
18
+ 888P Y888888 8888888888888 888 Y88888888888 888 Y8888
19
+ 888
20
+ Y8b d88P
21
+ Y88P
22
+ ".green
23
+ puts "
24
+ ** Pass the L1A Assessment **
25
+ ".green
26
+ end
27
+
28
+ self.logo
29
+
30
+ def self.questions
31
+
32
+ # score
33
+
34
+ @num_of_q = 0
35
+ @correct = 0
36
+
37
+ # question 1
38
+
39
+ prompt = TTY::Prompt.new
40
+ question = 'The primary migration process you will use as an L1a'
41
+ choices = %w(magic reparent internal geo-targeted)
42
+ answer = prompt.select(question, choices)
43
+ if answer == "magic"
44
+ puts ''
45
+ puts ' >> Correct! Magic Migrations are set in overdrive'
46
+ puts ''
47
+ @num_of_q += 1
48
+ @correct += 1
49
+ else
50
+ puts ''
51
+ puts ' >> Not quite... moving right along!'
52
+ puts ''
53
+ @num_of_q += 1
54
+ @correct = @correct
55
+ end
56
+
57
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
58
+ puts ''
59
+
60
+ # question 2
61
+
62
+ prompt = TTY::Prompt.new
63
+
64
+ answer = prompt.select('What is a M2p Migration?') do |menu|
65
+
66
+ menu.choice 'Member to Peer'
67
+ menu.choice 'Member to Platform'
68
+ menu.choice 'Move to preferred'
69
+ menu.choice 'Move to Peer'
70
+ end
71
+
72
+ if answer == "Move to preferred"
73
+ puts ''
74
+ puts ' >> Correct! Manual migration that can be done from the terminal (only to be used if the magic functionality is not available)'
75
+ puts ''
76
+ @num_of_q += 1
77
+ @correct += 1
78
+ else
79
+ puts ''
80
+ puts ' >> Not quite... Move to Preferred. Moving right along!'
81
+ puts ''
82
+ @num_of_q += 1
83
+ @correct = @correct
84
+ end
85
+
86
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
87
+ puts ''
88
+
89
+ # question 3
90
+
91
+ prompt = TTY::Prompt.new
92
+ answer = prompt.ask('File location of the Nginx access log? ... use \'install\' as the site name')
93
+
94
+ if answer == "/var/log/nginx/install.access.log"
95
+ puts ''
96
+ puts ' >> Correct!'
97
+ puts ''
98
+ @num_of_q += 1
99
+ @correct += 1
100
+ else
101
+ puts ''
102
+ puts ' >> Not quite... /var/log/nginx/install.access.log'
103
+ puts ''
104
+ @num_of_q += 1
105
+ @correct = @correct
106
+ end
107
+
108
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
109
+ puts ''
110
+
111
+ # question 4
112
+
113
+ prompt = TTY::Prompt.new
114
+ answer = prompt.ask('File location of the apachestyle Nginx access log? ... use \'install\' as the site name')
115
+
116
+ if answer == "/var/log/nginx/install.apachestyle.log"
117
+ puts ''
118
+ puts ' >> Correct! Note that the apachestyle logs are the Nginx logs, but keep the same formatting of the Apache logs'
119
+ puts ''
120
+ @num_of_q += 1
121
+ @correct += 1
122
+ else
123
+ puts ''
124
+ puts ' >> Not quite... /var/log/nginx/install.apachestyle.log'
125
+ puts ''
126
+ @num_of_q += 1
127
+ @correct = @correct
128
+ end
129
+
130
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
131
+ puts ''
132
+
133
+ # question 5
134
+
135
+ prompt = TTY::Prompt.new
136
+ answer = prompt.ask('File location for logs of killed apache processes?')
137
+
138
+ if answer == "/var/log/apache-killed-by-wpe.log"
139
+ puts ''
140
+ puts ' >> Correct!'
141
+ puts ''
142
+ @num_of_q += 1
143
+ @correct += 1
144
+ else
145
+ puts ''
146
+ puts ' >> Not quite... /var/log/apache-killed-by-wpe.log'
147
+ puts ''
148
+ @num_of_q += 1
149
+ @correct = @correct
150
+ end
151
+
152
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
153
+ puts ''
154
+
155
+ # question 6
156
+
157
+ prompt = TTY::Prompt.new
158
+ answer = prompt.ask('File location of the apache access log? ... use \'install\' as the site name')
159
+
160
+ if answer == "/var/log/apache2/install.access.log"
161
+ puts ''
162
+ puts ' >> Correct!'
163
+ puts ''
164
+ @num_of_q += 1
165
+ @correct += 1
166
+ else
167
+ puts ''
168
+ puts ' >> Not quite... /var/log/apache2/install.access.log'
169
+ puts ''
170
+ @num_of_q += 1
171
+ @correct = @correct
172
+ end
173
+
174
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
175
+ puts ''
176
+
177
+ # question 7
178
+
179
+ prompt = TTY::Prompt.new
180
+ answer = prompt.ask('File location of the apache error log? ... use \'install\' as the site name')
181
+
182
+ if answer == "/var/log/apache2/install.error.log"
183
+ puts ''
184
+ puts ' >> Correct!'
185
+ puts ''
186
+ @num_of_q += 1
187
+ @correct += 1
188
+ else
189
+ puts ''
190
+ puts ' >> Not quite... /var/log/apache2/install.error.log'
191
+ puts ''
192
+ @num_of_q += 1
193
+ @correct = @correct
194
+ end
195
+
196
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
197
+ puts ''
198
+
199
+ # question 8
200
+
201
+ prompt = TTY::Prompt.new
202
+ answer = prompt.select('$time_local|v1|$remote_addr|$http_host|$status|$body_bytes_sent|$upst ream_addr|$upstream_response_time|$request_time|$request|$is_logge d_as_bot|$is_prefetch|$http_cf_ray') do |menu|
203
+ menu.choice 'Apache log'
204
+ menu.choice 'Nginx log'
205
+ end
206
+
207
+ if answer == "Nginx log"
208
+ puts ''
209
+ puts ' >> Correct!'
210
+ puts ''
211
+ @num_of_q += 1
212
+ @correct += 1
213
+ else
214
+ puts ''
215
+ puts ' >> Not quite... this is a Nginx log'
216
+ puts ''
217
+ @num_of_q += 1
218
+ @correct = @correct
219
+ end
220
+
221
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
222
+ puts ''
223
+
224
+ # question 9
225
+
226
+ prompt = TTY::Prompt.new
227
+
228
+ answer = prompt.select('$remote_addr $http_host $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $wpe_user_agent') do |menu|
229
+ menu.choice 'Apache log'
230
+ menu.choice 'Nginx log'
231
+ end
232
+
233
+ if answer == "Apache log"
234
+ puts ''
235
+ puts ' >> Correct!'
236
+ puts ''
237
+ @num_of_q += 1
238
+ @correct += 1
239
+ else
240
+ puts ''
241
+ puts ' >> Not quite... this is a Apache log'
242
+ puts ''
243
+ @num_of_q += 1
244
+ @correct = @correct
245
+ end
246
+
247
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
248
+ puts ''
249
+
250
+ # question 10
251
+
252
+ prompt = TTY::Prompt.new
253
+ answer = prompt.ask('Linux command to output the first 10 lines of the file called wpengine.txt')
254
+
255
+ if answer == "head wpengine.txt"
256
+ puts ''
257
+ puts ' >> Correct!'
258
+ puts ''
259
+ @num_of_q += 1
260
+ @correct += 1
261
+ else
262
+ puts ''
263
+ puts ' >> Not quite... head wpengine.txt'
264
+ puts ''
265
+ @num_of_q += 1
266
+ @correct = @correct
267
+ end
268
+
269
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
270
+ puts ''
271
+
272
+ # question 11
273
+
274
+ prompt = TTY::Prompt.new
275
+ answer = prompt.ask('Linux command to output the last 10 lines of wpengine.txt')
276
+
277
+ if answer == "tail wpengine.txt"
278
+ puts ''
279
+ puts ' >> Correct!'
280
+ puts ''
281
+ @num_of_q += 1
282
+ @correct += 1
283
+ else
284
+ puts ''
285
+ puts ' >> Not quite... tail wpengine.txt'
286
+ puts ''
287
+ @num_of_q += 1
288
+ @correct = @correct
289
+ end
290
+
291
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
292
+ puts ''
293
+
294
+ # question 12
295
+
296
+ prompt = TTY::Prompt.new
297
+ answer = prompt.ask('Linux command to show directory space usage in KB/MB/GB')
298
+
299
+ if answer == "du -sh *"
300
+ puts ''
301
+ puts ' >> Correct!'
302
+ puts ''
303
+ @num_of_q += 1
304
+ @correct += 1
305
+ else
306
+ puts ''
307
+ puts ' >> Not quite... du -sh *'
308
+ puts ''
309
+ @num_of_q += 1
310
+ @correct = @correct
311
+ end
312
+
313
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
314
+ puts ''
315
+
316
+ # question 13
317
+
318
+ prompt = TTY::Prompt.new
319
+ answer = prompt.ask('Linux command to show disk usage... mainly for the cluster, shows the % at which the server is loading memory')
320
+
321
+ if answer == "df -h"
322
+ puts ''
323
+ puts ' >> Correct!'
324
+ puts ''
325
+ @num_of_q += 1
326
+ @correct += 1
327
+ else
328
+ puts ''
329
+ puts ' >> Not quite... df -h'
330
+ puts ''
331
+ @num_of_q += 1
332
+ @correct = @correct
333
+ end
334
+
335
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
336
+ puts ''
337
+
338
+
339
+ # question 14
340
+
341
+ prompt = TTY::Prompt.new
342
+ answer = prompt.ask('Linux command to show how much CPU % and Memory % is being used and which processes are using them the most')
343
+
344
+ if answer == "htop"
345
+ puts ''
346
+ puts ' >> Correct!'
347
+ puts ''
348
+ @num_of_q += 1
349
+ @correct += 1
350
+ else
351
+ puts ''
352
+ puts ' >> Not quite... htop'
353
+ puts ''
354
+ @num_of_q += 1
355
+ @correct = @correct
356
+ end
357
+
358
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
359
+ puts ''
360
+
361
+ # question 15
362
+
363
+ prompt = TTY::Prompt.new
364
+ answer = prompt.ask('Linux command to show the status of the server throughout a specific point in time')
365
+
366
+ if answer == "sar -q"
367
+ puts ''
368
+ puts ' >> Correct!'
369
+ puts ''
370
+ @num_of_q += 1
371
+ @correct += 1
372
+ else
373
+ puts ''
374
+ puts ' >> Not quite... sar -q'
375
+ puts ''
376
+ @num_of_q += 1
377
+ @correct = @correct
378
+ end
379
+
380
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
381
+ puts ''
382
+
383
+ # question 16
384
+
385
+ prompt = TTY::Prompt.new
386
+ answer = prompt.ask('Linux command to show the number of cores currently on the server/cluster')
387
+
388
+ if answer == "nproc"
389
+ puts ''
390
+ puts ' >> Correct!'
391
+ puts ''
392
+ @num_of_q += 1
393
+ @correct += 1
394
+ else
395
+ puts ''
396
+ puts ' >> Not quite... nproc'
397
+ puts ''
398
+ @num_of_q += 1
399
+ @correct = @correct
400
+ end
401
+
402
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
403
+ puts ''
404
+
405
+ # question 17
406
+
407
+ prompt = TTY::Prompt.new
408
+ answer = prompt.ask('Linux command to find the amount of Memory on a current server and how much is being utilized')
409
+
410
+ if answer == "free"
411
+ puts ''
412
+ puts ' >> Correct!'
413
+ puts ''
414
+ @num_of_q += 1
415
+ @correct += 1
416
+ else
417
+ puts ''
418
+ puts ' >> Not quite... free'
419
+ puts ''
420
+ @num_of_q += 1
421
+ @correct = @correct
422
+ end
423
+
424
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
425
+ puts ''
426
+
427
+ # question 18
428
+
429
+ prompt = TTY::Prompt.new
430
+ answer = prompt.ask('What\'s the WP-CLI command you\'d run, when reverting a site from core version 5.7 to 5.5.6?')
431
+
432
+ if answer == "wp core update --version=5.5.6 --force"
433
+ puts ''
434
+ puts ' >> Correct!'
435
+ puts ''
436
+ @num_of_q += 1
437
+ @correct += 1
438
+ else
439
+ puts ''
440
+ puts ' >> Not quite... wp core update --version=5.5.6 --force'
441
+ puts ''
442
+ @num_of_q += 1
443
+ @correct = @correct
444
+ end
445
+
446
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
447
+ puts ''
448
+
449
+ # question 19
450
+
451
+ prompt = TTY::Prompt.new
452
+ answer = prompt.ask('Linux command to find all files with extention .git')
453
+
454
+ if answer == "find -name \"*.git\""
455
+ puts ''
456
+ puts ' >> Correct!'
457
+ puts ''
458
+ @num_of_q += 1
459
+ @correct += 1
460
+ else
461
+ puts ''
462
+ puts ' >> Not quite... find -name \"*.git\"'
463
+ puts ''
464
+ @num_of_q += 1
465
+ @correct = @correct
466
+ end
467
+
468
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
469
+ puts ''
470
+
471
+ # question 20
472
+
473
+ prompt = TTY::Prompt.new
474
+
475
+ answer = prompt.select('/nas/config/live/installname/ is a ...') do |menu|
476
+ menu.choice 'Absolute Path'
477
+ menu.choice 'Relative Path'
478
+ end
479
+
480
+ if answer == "Absolute Path"
481
+ puts ''
482
+ puts ' >> Correct! Referring to everything based on the root directory and always starting with a /'
483
+ puts ''
484
+ @num_of_q += 1
485
+ @correct += 1
486
+ else
487
+ puts ''
488
+ puts ' >> Not quite... Absolute Path'
489
+ puts ''
490
+ @num_of_q += 1
491
+ @correct = @correct
492
+ end
493
+
494
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
495
+ puts ''
496
+
497
+ # question 21
498
+
499
+ prompt = TTY::Prompt.new
500
+
501
+ answer = prompt.select('_wpeprivate/ is a ...') do |menu|
502
+ menu.choice 'Absolute Path'
503
+ menu.choice 'Relative Path'
504
+ end
505
+
506
+ if answer == "Relative Path"
507
+ puts ''
508
+ puts ' >> Correct! Command on what you want to operate on relative to where you are. Interacts with current directory.'
509
+ puts ''
510
+ @num_of_q += 1
511
+ @correct += 1
512
+ else
513
+ puts ''
514
+ puts ' >> Not quite... Relative Path'
515
+ puts ''
516
+ @num_of_q += 1
517
+ @correct = @correct
518
+ end
519
+
520
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
521
+ puts ''
522
+
523
+ # question 22
524
+
525
+ prompt = TTY::Prompt.new
526
+ answer = prompt.ask('Cut command to find top ten page requests, requested by googlebot from 10-11 am utc: ... use \'install\' as the name of the envrionment + the year 2021')
527
+
528
+ if answer == "grep \'2021:10\' /var/log/nginx/install.apachestyle.log | grep -i \'googlebot\' | cut -d\' \' -f2 | sort | uniq -c | sort -nr | head"
529
+ puts ''
530
+ puts ' >> Correct!'
531
+ puts ''
532
+ @num_of_q += 1
533
+ @correct += 1
534
+ else
535
+ puts ''
536
+ puts ' >> Not quite... grep \'2021:10\' /var/log/nginx/install.apachestyle.log | grep -i \'googlebot\' | cut -d\' \' -f2 | sort | uniq -c | sort -nr | head'
537
+ puts ''
538
+ @num_of_q += 1
539
+ @correct = @correct
540
+ end
541
+
542
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
543
+ puts ''
544
+
545
+ # question 23
546
+
547
+ prompt = TTY::Prompt.new
548
+ answer = prompt.ask('Cut command to find Top Ten IP’s that hit today ... use the \'install\' as the name of the environment')
549
+
550
+ if answer == "cut -d\" \" -f1 /var/log/nginx/install.apachestyle.log | sort | uniq -c | sort -rn | head"
551
+ puts ''
552
+ puts ' >> Correct!'
553
+ puts ''
554
+ @num_of_q += 1
555
+ @correct += 1
556
+ else
557
+ puts ''
558
+ puts ' >> Not quite... cut -d\' \' -f1 /var/log/nginx/install.apachestyle.log | sort | uniq -c | sort -rn | head'
559
+ puts ''
560
+ @num_of_q += 1
561
+ @correct = @correct
562
+ end
563
+
564
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
565
+ puts ''
566
+
567
+ # question 24
568
+
569
+ prompt = TTY::Prompt.new
570
+ answer = prompt.ask('Top ten pages that Googlebot hit 2 days ago ... use the \'install\' as the name of the environment')
571
+
572
+ if answer == "zgrep \'Googlebot\' /var/log/nginx/install.apachestyle.log.2.gz | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head"
573
+ puts ''
574
+ puts ' >> Correct!'
575
+ puts ''
576
+ @num_of_q += 1
577
+ @correct += 1
578
+ else
579
+ puts ''
580
+ puts ' >> Not quite... zgrep \'Googlebot\' /var/log/nginx/install.apachestyle.log.2.gz | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head'
581
+ puts ''
582
+ @num_of_q += 1
583
+ @correct = @correct
584
+ end
585
+
586
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
587
+ puts ''
588
+
589
+ # question 25
590
+
591
+ prompt = TTY::Prompt.new
592
+ answer = prompt.ask('Top ten pages that Googlebot has hit today ... use the \'install\' as the name of the environment')
593
+
594
+ if answer == "grep \'Googlebot\' /var/log/nginx/install.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head"
595
+ puts ''
596
+ puts ' >> Correct!'
597
+ puts ''
598
+ @num_of_q += 1
599
+ @correct += 1
600
+ else
601
+ puts ''
602
+ puts ' >> Not quite... grep \'Googlebot\' /var/log/nginx/install.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head'
603
+ puts ''
604
+ @num_of_q += 1
605
+ @correct = @correct
606
+ end
607
+
608
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
609
+ puts ''
610
+
611
+ # question 26
612
+
613
+ prompt = TTY::Prompt.new
614
+
615
+ answer = prompt.select('Which type of log will show the user agent?') do |menu|
616
+ menu.choice 'Nginx'
617
+ menu.choice 'Apachestyle Nginx'
618
+ menu.choice 'Apache'
619
+ end
620
+
621
+ if answer == "Apachestyle Nginx"
622
+ puts ''
623
+ puts ' >> Correct!'
624
+ puts ''
625
+ @num_of_q += 1
626
+ @correct += 1
627
+ else
628
+ puts ''
629
+ puts ' >> Not quite... Apachestyle Nginx'
630
+ puts ''
631
+ @num_of_q += 1
632
+ @correct = @correct
633
+ end
634
+
635
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
636
+ puts ''
637
+
638
+ # question 27
639
+
640
+ prompt = TTY::Prompt.new
641
+ answer = prompt.ask('Top Ten pages that had a 504 response code')
642
+
643
+ if answer == "grep \"504\" /var/log/nginx/install.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head"
644
+ puts ''
645
+ puts ' >> Correct!'
646
+ puts ''
647
+ @num_of_q += 1
648
+ @correct += 1
649
+ else
650
+ puts ''
651
+ puts ' >> Not quite... grep \"504\" /var/log/nginx/install.apachestyle.log | cut -d\' \' -f7 | sort | uniq -c | sort -rn | head'
652
+ puts ''
653
+ @num_of_q += 1
654
+ @correct = @correct
655
+ end
656
+
657
+ puts " | #{@correct} | out of #{@num_of_q} questions correct".green
658
+ puts ''
659
+ end
660
+
661
+ self.questions
662
+
663
+ def self.fireworks
664
+ system("bash fireworks.sh")
665
+ end
666
+
667
+ self.fireworks
668
+
669
+ end
670
+
671
+
672
+