blob: aa8f831752b3f728a26fc2babbc89c17b8dc8e01 [file] [log] [blame]
Joy Onyerikwu223f1752018-02-21 18:08:02 -06001#!/bin/bash
2#\
3exec expect "$0" -- ${1+"$@"}
4
5# This file contains utilities for working with Serial over Lan (SOL).
6
7# Example use case:
8# sol_utils.tcl --os_host=ip --os_password=password --os_username=username
9# --openbmc_host=ip --openbmc_password=password --openbmc_username=username
10# --proc_name=boot_to_petitboot
11
12source [exec bash -c "which source.tcl"]
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -050013my_source \
14[list print.tcl opt.tcl valid.tcl call_stack.tcl tools.exp cmd.tcl host.tcl]
Joy Onyerikwu223f1752018-02-21 18:08:02 -060015
16longoptions openbmc_host: openbmc_username:=root openbmc_password:=0penBmc\
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -050017 os_host: os_username:=root os_password: proc_name: ftp_username: \
18 ftp_password: os_repo_url: test_mode:=0 quiet:=0 debug:=0
Joy Onyerikwu223f1752018-02-21 18:08:02 -060019pos_parms
20
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -050021set valid_proc_name [list os_login boot_to_petitboot go_to_petitboot_shell \
22 install_os time_settings software_selection root_password]
Joy Onyerikwu223f1752018-02-21 18:08:02 -060023
24# Create help dictionary for call to gen_print_help.
25set help_dict [dict create\
26 ${program_name} [list "${program_name} is an SOL utilities program that\
27 will run the user's choice of utilities. See the \"proc_name\" parm below\
28 for details."]\
29 openbmc_host [list "The OpenBMC host name or IP address." "host"]\
30 openbmc_username [list "The OpenBMC username." "username"]\
31 openbmc_password [list "The OpenBMC password." "password"]\
32 os_host [list "The OS host name or IP address." "host"]\
33 os_username [list "The OS username." "username"]\
34 os_password [list "The OS password." "password"]\
35 proc_name [list "The proc_name you'd like to run. Valid values are as\
36 follows: [regsub -all {\s+} $valid_proc_name {, }]."]\
37]
38
39
40# Setup state dictionary.
41set state [dict create\
42 ssh_logged_in 0\
43 os_login_prompt 0\
44 os_logged_in 0\
45 petitboot_screen 0\
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -050046 petitboot_shell_prompt 0\
Joy Onyerikwu223f1752018-02-21 18:08:02 -060047]
48
49
50proc help {} {
51
52 gen_print_help
53
54}
55
56
57proc exit_proc { {ret_code 0} } {
58
59 # Execute whenever the program ends normally or with the signals that we
60 # catch (i.e. TERM, INT).
61
62 dprintn ; dprint_executing
63 dprint_var ret_code
64
65 set cmd_buf os_logoff
66 qprintn ; qprint_issuing
67 eval ${cmd_buf}
68
69 set cmd_buf sol_logoff
70 qprintn ; qprint_issuing
71 eval ${cmd_buf}
72
73 qprint_pgm_footer
74
75 exit $ret_code
76
77}
78
79
80proc validate_parms {} {
81
82 trap { exit_proc } [list SIGTERM SIGINT]
83
84 valid_value openbmc_host
85 valid_value openbmc_username
86 valid_value openbmc_password
87 valid_value os_host
88 valid_value os_username
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -050089 valid_password os_password
Joy Onyerikwu223f1752018-02-21 18:08:02 -060090 global valid_proc_name
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -050091 global proc_name proc_names
92 set proc_names [split $proc_name " "]
93 if { $proc_name == "install_os"} {
94 valid_value ftp_username
95 valid_password ftp_password
96 valid_value os_repo_url
97 }
Joy Onyerikwu223f1752018-02-21 18:08:02 -060098
99}
100
101
102proc sol_login {} {
103
104 # Login to the SOL console.
105
106 dprintn ; dprint_executing
107
108 global spawn_id
109 global expect_out
110 global state
111 global openbmc_host openbmc_username openbmc_password
112 global cr_lf_regex
113 global ssh_password_prompt
114
115 set cmd_buf "spawn -nottycopy ssh -p 2200 $openbmc_username@$openbmc_host"
116 qprint_issuing
117 eval $cmd_buf
118
119 append bad_host_regex "ssh: Could not resolve hostname ${openbmc_host}:"
120 append bad_host_regex " Name or service not known"
121 set expect_result [expect_wrap\
122 [list $bad_host_regex $ssh_password_prompt]\
123 "an SOL password prompt" 5]
124
125 if { $expect_result == 0 } {
126 puts stderr ""
127 print_error "Invalid openbmc_host value.\n"
128 exit_proc 1
129 }
130
131 send_wrap "${openbmc_password}"
132
133 append bad_user_pw_regex "Permission denied, please try again\."
134 append bad_user_pw_regex "${cr_lf_regex}${ssh_password_prompt}"
135 set expect_result [expect_wrap\
136 [list $bad_user_pw_regex "sh: xauth: command not found"]\
137 "an SOL prompt" 10]
138
139 switch $expect_result {
140 0 {
141 puts stderr "" ; print_error "Invalid OpenBmc username or password.\n"
142 exit_proc 1
143 }
144 1 {
145 # Currently, this string always appears but that is not necessarily
146 # guaranteed.
147 dict set state ssh_logged_in 1
148 }
149 }
150
151 if { [dict get $state ssh_logged_in] } {
152 qprintn ; qprint_timen "Logged into SOL."
153 dprintn ; dprint_dict state
154 return
155 }
156
157 # If we didn't get a hit on the "sh: xauth: command not found", then we just
158 # need to see a linefeed.
159 set expect_result [expect_wrap [list ${cr_lf_regex}] "an SOL prompt" 5]
160
161 dict set state ssh_logged_in 1
162 qprintn ; qprint_timen "Logged into SOL."
163 dprintn ; dprint_dict state
164
165}
166
167
168proc sol_logoff {} {
169
170 # Logoff from the SOL console.
171
172 dprintn ; dprint_executing
173
174 global spawn_id
175 global expect_out
176 global state
177 global openbmc_host
178
179 if { ! [dict get $state ssh_logged_in] } {
180 qprintn ; qprint_timen "No SOL logoff required."
181 return
182 }
183
184 send_wrap "~."
185
186 set expect_result [expect_wrap\
187 [list "Connection to $openbmc_host closed"]\
188 "a connection closed message" 5]
189
190 dict set state ssh_logged_in 0
191 qprintn ; qprint_timen "Logged off SOL."
192 dprintn ; dprint_dict state
193
194}
195
196
197proc get_post_ssh_login_state {} {
198
199 # Get the initial state following sol_login.
200
201 # The following state global dictionary variable is set by this procedure.
202
203 dprintn ; dprint_executing
204
205 global spawn_id
206 global expect_out
207 global state
208 global os_login_prompt_regex
209 global os_prompt_regex
210 global petitboot_screen_regex
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500211 global petitboot_shell_prompt_regex
212 global installer_screen_regex
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600213
214 if { ! [dict get $state ssh_logged_in] } {
215 puts stderr ""
216 append message "Programmer error - [get_stack_proc_name] must only be"
217 append message " called after sol_login has been called."
218 print_error_report $message
219 exit_proc 1
220 }
221
222 # The first thing one must do after signing into ssh -p 2200 is hit enter to
223 # see where things stand.
224 send_wrap ""
225 set expect_result [expect_wrap\
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500226 [list $os_login_prompt_regex $os_prompt_regex $petitboot_screen_regex \
227 $petitboot_shell_prompt_regex $installer_screen_regex] \
228 "any indication of status" 5 0]
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600229
230 switch $expect_result {
231 0 {
232 dict set state os_login_prompt 1
233 }
234 1 {
235 dict set state os_logged_in 1
236 }
237 2 {
238 dict set state petitboot_screen 1
239 }
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500240 3 {
241 dict set state petitboot_shell_prompt 1
242 }
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600243 }
244
245 dprintn ; dprint_dict state
246
247}
248
249
250proc os_login {} {
251
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500252 # Login to the OS.
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600253
254 dprintn ; dprint_executing
255
256 global spawn_id
257 global expect_out
258 global state
259 global openbmc_host os_username os_password
260 global os_password_prompt
261 global os_prompt_regex
262
263 if { [dict get $state os_logged_in] } {
264 printn ; print_timen "We are already logged in to the OS."
265 return
266 }
267
268 send_wrap "${os_username}"
269
270 append bad_host_regex "ssh: Could not resolve hostname ${openbmc_host}:"
271 append bad_host_regex " Name or service not known"
272 set expect_result [expect_wrap\
273 [list $os_password_prompt]\
274 "an OS password prompt" 5]
275
276 send_wrap "${os_password}"
277 set expect_result [expect_wrap\
278 [list "Login incorrect" "$os_prompt_regex"]\
279 "an OS prompt" 10]
280 switch $expect_result {
281 0 {
282 puts stderr "" ; print_error "Invalid OS username or password.\n"
283 exit_proc 1
284 }
285 }
286
287 dict set state os_logged_in 1
288 dict set state os_login_prompt 0
289 qprintn ; qprint_timen "Logged into OS."
290 dprintn ; dprint_dict state
291
292}
293
294
295proc os_logoff {} {
296
297 # Logoff from the SOL console.
298
299 dprintn ; dprint_executing
300
301 global spawn_id
302 global expect_out
303 global state
304 global os_login_prompt_regex
305
306 if { ! [dict get $state os_logged_in] } {
307 qprintn ; qprint_timen "No OS logoff required."
308 return
309 }
310
311 send_wrap "exit"
312 set expect_result [expect_wrap\
313 [list $os_login_prompt_regex]\
314 "an OS prompt" 5]
315
316 dict set state os_logged_in 0
317 qprintn ; qprint_timen "Logged off OS."
318 dprintn ; dprint_dict state
319
320}
321
322
323proc os_command {command_string { quiet {} } { test_mode {} } \
324 { show_err {} } { ignore_err {} } {trim_cr_lf 1}} {
325
326 # Execute the command_string on the OS command line and return a list
327 # consisting of 1) the return code of the command 2) the stdout/
328 # stderr.
329
330 # It is the caller's responsibility to make sure we are logged into the OS.
331
332 # Description of argument(s):
333 # command_string The command string which is to be run on the OS (e.g.
334 # "hostname" or "grep this that").
335 # quiet Indicates whether this procedure should run the
336 # print_issuing() procedure which prints "Issuing:
337 # <cmd string>" to stdout. The default value is 0.
338 # test_mode If test_mode is set, this procedure will not actually run
339 # the command. If print_output is set, it will print
340 # "(test_mode) Issuing: <cmd string>" to stdout. The default
341 # value is 0.
342 # show_err If show_err is set, this procedure will print a
343 # standardized error report if the shell command returns non-
344 # zero. The default value is 1.
345 # ignore_err If ignore_err is set, this procedure will not fail if the
346 # shell command fails. However, if ignore_err is not set,
347 # this procedure will exit 1 if the shell command fails. The
348 # default value is 1.
349 # trim_cr_lf Trim any trailing carriage return or line feed from the
350 # result.
351
352 # Set defaults (this section allows users to pass blank values for certain
353 # args)
354 set_var_default quiet [get_stack_var quiet 0 2]
355 set_var_default test_mode 0
356 set_var_default show_err 1
357 set_var_default ignore_err 0
358 set_var_default acceptable_shell_rcs 0
359
360 global spawn_id
361 global expect_out
362 global os_prompt_regex
363
364 qprintn ; qprint_issuing ${command_string} ${test_mode}
365
366 if { $test_mode } {
367 return [list 0 ""]
368 }
369
370 send_wrap "${command_string}"
371
372 set expect_result [expect_wrap\
373 [list "-ex $command_string"]\
374 "the echoed command" 5]
375 set expect_result [expect_wrap\
376 [list {[\n\r]{1,2}}]\
377 "one or two line feeds" 5]
378 # Note the non-greedy specification in the regex below (the "?").
379 set expect_result [expect_wrap\
380 [list "(.*?)$os_prompt_regex"]\
381 "command output plus prompt" -1]
382
383 # The command's stdout/stderr should be captured as match #1.
384 set out_buf $expect_out(1,string)
385
386 if { $trim_cr_lf } {
387 set out_buf [ string trimright $out_buf "\r\n" ]
388 }
389
390 # Get rc via recursive call to this function.
391 set rc 0
392 set proc_name [get_stack_proc_name]
393 set calling_proc_name [get_stack_proc_name -2]
394 if { $calling_proc_name != $proc_name } {
395 set sub_result [os_command {echo ${?}} 1]
396 dprintn ; dprint_list sub_result
397 set rc [lindex $sub_result 1]
398 }
399
400 if { $rc != 0 } {
401 if { $show_err } {
402 puts stderr "" ; print_error_report "The prior OS command failed.\n"
403 }
404 if { ! $ignore_err } {
405 if { [info procs "exit_proc"] != "" } {
406 exit_proc 1
407 }
408 }
409 }
410
411 return [list $rc $out_buf]
412
413}
414
415
416proc boot_to_petitboot {} {
417
418 # Boot the machine until the petitboot screen is reached.
419
420 dprintn ; dprint_executing
421
422 global spawn_id
423 global expect_out
424 global state
425 global os_prompt_regex
426 global petitboot_screen_regex
427
428 if { [dict get $state petitboot_screen] } {
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500429 qprintn ; qprint_timen "Already at petiboot."
430 return
431 }
432
433 if { [dict get $state petitboot_shell_prompt] } {
434 qprintn ; qprint_timen "Now at the shell prompt. Going to petitboot."
435 send_wrap "exit"
436 set expect_result [expect_wrap [list $petitboot_screen_regex]\
437 "the petitboot screen" 900]
438 dict set state petitboot_shell_prompt 0
439 dict set state petitboot_screen 1
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600440 return
441 }
442
443 if { [dict get $state os_login_prompt] } {
444 set cmd_buf os_login
445 qprintn ; qprint_issuing
446 eval ${cmd_buf}
447 }
448
449 # Turn off autoboot.
450 set cmd_result [os_command "nvram --update-config auto-boot?=false"]
451 set cmd_result [os_command\
452 "nvram --print-config | egrep 'auto\\-boot\\?=false'"]
453
454 # Reboot and wait for petitboot.
455 send_wrap "reboot"
456
457 # Once we've started a reboot, we are no longer logged into OS.
458 dict set state os_logged_in 0
459 dict set state os_login_prompt 0
460
461 set expect_result [expect_wrap\
462 [list $petitboot_screen_regex]\
463 "the petitboot screen" 900]
464 set expect_result [expect_wrap\
465 [list "Exit to shell"]\
466 "the 'Exit to shell' screen" 10]
467 dict set state petitboot_screen 1
468
469 qprintn ; qprint_timen "Arrived at petitboot screen."
470 dprintn ; dprint_dict state
471
472}
473
474
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500475proc go_to_petitboot_shell {} {
476
477 # Go to petitboot shell.
478 global spawn_id
479 global state
480 global expect_out
481 global petitboot_shell_prompt_regex
482
483 if { [dict get $state petitboot_shell_prompt] } {
484 qprintn ; qprint_timen "Already at the shell prompt."
485 return
486 }
487
488 eval boot_to_petitboot
489 send_wrap "x"
490 set expect_result [expect_wrap [list $petitboot_shell_prompt_regex]\
491 "the shell prompt" 10]
492 dict set state petitboot_screen 0
493 dict set state petitboot_shell_prompt 1
494 qprintn ; qprint_timen "Arrived at the shell prompt."
495 qprintn ; qprint_timen state
496
497}
498
499
500proc installation_destination {} {
501
502 # Set the software installation destination.
503
504 # Expectation is that we are starting at the "Installation" options screen.
505
506 dprintn ; dprint_executing
507
508 global spawn_id
509 global expect_out
510 global state
511 global installer_screen_regex
512
513 qprintn ; qprint_timen "Presumed to be at \"Installation\" screen."
514
515 qprintn ; qprint_timen "Setting Installation Destination."
516 # Option 5). Installation Destination
517 qprintn ; qprint_timen "Selecting \"Installation Destination\" option."
518 send_wrap "5"
519 expect_wrap [list "Installation Destination"] "installation destination\
520 menu" 30
521
522 qprintn ; qprint_timen "Selecting \"Select all\" option."
523 send_wrap "3"
524 expect_wrap [list "Select all"] "selected all disks" 10
525
526 qprintn ; qprint_timen "Selecting \"continue\" option."
527 send_wrap "c"
528 expect_wrap [list "Autopartitioning"] "autopartitioning options" 10
529
530 qprintn ; qprint_timen "\
531 Selecting \"Replace Existing Linux system(s)\" option."
532 send_wrap "1"
533 expect_wrap [list "Replace"] "selected stanard partition" 10
534
535 qprintn ; qprint_timen "Selecting \"continue\" option."
536 send_wrap "c"
537 expect_wrap [list "Partition Scheme"] "partition scheme options" 10
538
539 qprintn ; qprint_timen "Selecting \"LVM\" option."
540 send_wrap "3"
541 expect_wrap [list "LVM"] "lvm option" 10
542
543 qprintn ; qprint_timen "Selecting \"continue\" option."
544 send_wrap "c"
545 expect_wrap [list $installer_screen_regex] "installation options screen" 10
546
547}
548
549
550proc time_settings {} {
551
552 # Set the time/zone via the petitboot shell prompt "Time settings" menu.
553
554 # Expectation is that we are starting at the "Installation" options screen.
555
556 dprintn ; dprint_executing
557
558 global spawn_id
559 global expect_out
560 global state
561 global installer_screen_regex
562
563 # Option 2). Timezone.
564
565 qprintn ; qprint_timen "Presumed to be at \"Installation\" screen."
566 qprintn ; qprint_timen "Setting time."
567
568 qprintn ; qprint_timen "Selecting \"Time settings\"."
569 send_wrap "2"
570 expect_wrap [list "Set timezone" "Time settings"] "Time settings menu" 30
571
572 qprintn ; qprint_timen "Selecting \"Change timezone\"."
573 send_wrap "1"
574 expect_wrap [list "Available regions"] "available regions menu" 10
575
576 qprintn ; qprint_timen "Selecting \"US\"."
577 send_wrap "11"
578 expect_wrap [list "region US"] "select region in US menu" 10
579
580 qprintn ; qprint_timen "Selecting \"Central\"."
581 send_wrap "3"
582 expect_wrap [list $installer_screen_regex] "installation options screen" 10
583
584}
585
586
587proc software_selection {} {
588
589 # Set the base environment via the petitboot shell prompt
590 # "Software Selection" menu.
591
592 # Expectation is that we are starting at the "Installation" options
593 # screen.
594
595 dprintn ; dprint_executing
596
597 global spawn_id
598 global expect_out
599 global state
600 global installer_screen_regex
601
602 qprintn ; qprint_timen "Presumed to be at \"Installation\" screen."
603 qprintn ; qprint_timen "Software selection."
604 # Option 4). Software selection.
605 set expect_result 0
606 while { $expect_result != 1 } {
607 qprintn ; qprint_timen "Selecting \"Software selection\"."
608 send_wrap "4"
609 set expect_result [expect_wrap\
610 [list "Installation source needs to be set up first." \
611 "Base environment"] "base environment menu" 10 0]
612
613 switch $expect_result {
614 0 {
615 qprintn ; qprint_timen "Selecting \"continue\"."
616 send_wrap "c"
617 expect_wrap [list $installer_screen_regex] \
618 "installation options screen" 15
619 }
620 1 {
621 break
622 }
623 }
624 }
625
626 qprintn ; qprint_timen "Selecting \"Infrastructure Server\"."
627 send_wrap "2"
628 expect_wrap [list "Infrastructure"] "selected infrastructure" 15
629
630 qprintn ; qprint_timen "Selecting \"continue\"."
631 send_wrap "c"
632 expect_wrap [list $installer_screen_regex] "installation options screen" 15
633
634}
635
636
637proc root_password {} {
638
639 # Set the os root password via the petitboot shell prompt "Root password"
640 # option.
641
642 # Expectation is that we are starting at the "Installation" options screen.
643
644 dprintn ; dprint_executing
645
646 global spawn_id
647 global expect_out
648 global state
649 global os_password
650 global installer_screen_regex
651
652 qprintn ; qprint_timen "Presumed to be at \"Installation\" screen."
653 qprintn ; qprint_timen "Setting root password."
654
655 # Option 8). Root password.
656 qprintn ; qprint_timen "Selecting \"Root password\"."
657 send_wrap "8"
658 expect_wrap [list "Password:"] "root password prompt" 30
659
660 qprintn ; qprint_timen "Entering root password."
661 send_wrap "$os_password"
662 expect_wrap [list "confirm"] "comfirm root password prompt" 15
663
664 qprintn ; qprint_timen "Re-entering root password."
665 send_wrap "$os_password"
666 set expect_result [expect_wrap\
667 [list $installer_screen_regex "The password you have provided is weak"] \
668 "root password accepted" 10 0]
669 switch $expect_result {
670 0 {
671 break
672 }
673 1 {
674 qprintn ; qprint_timen "Confirming weak password."
675 send_wrap "yes"
676 }
677 }
678 expect_wrap [list $installer_screen_regex] "installation options screen" 10
679
680}
681
682
683proc install_os {} {
684
685 # Install an os on the machine.
686 global spawn_id
687 global expect_out
688 global petitboot_shell_prompt_regex
689 global installer_screen_regex
690 global ftp_username ftp_password os_repo_url
691 global os_host os_username os_password
692
693 lassign [get_host_name_ip $os_host 0] os_hostname short_host_name ip_address
694 set netmask [get_host_netmask $os_host $os_username $os_password 0]
695 set gateway [get_host_gateway $os_host $os_username $os_password 0]
696 set mac_address [get_host_mac_address $os_host $os_username $os_password "" 0]
697 set name_servers [get_host_name_servers $os_host $os_username $os_password "" 0]
698 set dns [lindex $name_servers 0]
699 set domain [get_host_domain $os_host $os_username $os_password 0]
700 exit_proc
701 # Go to shell and download files for installation
702 eval go_to_petitboot_shell
703 after 10000
704 set vmlinuz_url \
705 "ftp://$ftp_username:$ftp_password@$os_repo_url/ppc/ppc64/vmlinuz"
706 set initrd_url \
707 "ftp://$ftp_username:$ftp_password@$os_repo_url/ppc/ppc64/initrd.img"
708 send_wrap "wget -c $vmlinuz_url"
709 expect_wrap [list "vmlinuz *100%"] "wget vmlinuz file success" 30
710 send_wrap "wget -c $initrd_url"
711 expect_wrap [list "initrd.img *100%"] "wget initrd file success" 30
712
713 # Setup parms and run kexec.
714 set colon "::"
715 set squashfs_url \
716 "ftp://$ftp_username:$ftp_password@$os_repo_url/LiveOS/squashfs.img"
717 set kexec_args "kexec -l vmlinuz --initrd initrd.img\
718 --append='root=live:$squashfs_url \
719 repo=ftp://$ftp_username:$ftp_password@$os_repo_url rd.dm=0 rd.md=0\
720 nodmraid console=hvc0 ifname=net0:$mac_address\
721 ip=$os_host$colon$gateway:$netmask:$os_hostname:net0:none nameserver=$dns\
722 inst.text'"
723 send_wrap "$kexec_args"
724 dprintn ; dprint_vars expect_out
725 set expect_result [expect_wrap [list $petitboot_shell_prompt_regex]\
726 "the shell prompt" 10]
727
728 # Turn on autoboot.
729 send_wrap "nvram --update-config auto-boot?=true"
730 send_wrap "nvram --print-config | egrep 'auto\\-boot\\?=true'"
731
732 send_wrap "kexec -e"
733
734 # Begin installation process, go to settings screen.
735 set expect_result [expect_wrap [list "Starting installer"]\
736 "starting installer log" 900]
737 set expect_result [expect_wrap [list "Use text mode"]\
738 "install mode selection prompt" 120]
739 send_wrap "2"
740 expect_wrap [list $installer_screen_regex] "installation options screen" 15
741
742 installation_destination
743 time_settings
744 software_selection
745 root_password
746
747 # Now begin installation process.
748 set expect_result [expect_wrap\
749 [list $os_repo_url "Processing..."] \
750 "installation source processing" 10 0]
751
752 switch $expect_result {
753 0 {
754 break
755 }
756 1 {
757 expect_wrap [list $os_repo_url] "source processing complete" 240
758 }
759 }
760 send_wrap "b"
761 set expect_result [expect_wrap \
762 [list "Installation complete* Press return to quit"] \
763 "os installation complete message" 2000]
764 send_wrap ""; # Reboots to petitboot.
765 return
766
767}
768
769
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600770# Main
771
772 gen_get_options $argv
773
774 validate_parms
775
776 qprint_pgm_header
777
778 # Global variables for current prompts of the SOL console.
779 set ssh_password_prompt ".* password: "
780 set os_login_prompt_regex "login: "
781 set os_password_prompt "Password: "
782 set petitboot_screen_regex "Petitboot"
783 set cr_lf_regex "\[\n\r\]"
784 set os_prompt_regex "(\\\[${os_username}@\[^ \]+ ~\\\]# )"
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500785 set petitboot_shell_prompt_regex "/ #"
786 set installer_screen_regex \
787 {Installation[\r\n].*Please make your choice from above.* to refresh\]: }
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600788
789 dprintn ; dprint_dict state
790
791 set cmd_buf sol_login
792 qprint_issuing
793 eval ${cmd_buf}
794
795 set cmd_buf get_post_ssh_login_state
796 qprintn ; qprint_issuing
797 eval ${cmd_buf}
798
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500799 foreach proc_name $proc_names {
800 set cmd_buf ${proc_name}
801 qprintn ; qprint_issuing
802 eval ${cmd_buf}
803 }
Joy Onyerikwu223f1752018-02-21 18:08:02 -0600804
Joy Onyerikwufcb8aea2018-03-21 14:57:44 -0500805 exit_proc