blob: a34f6f4193df480a8a467701abd601e132187c2d [file] [log] [blame]
Steven Rostedt2545eb62010-11-02 15:01:32 -04001#!/usr/bin/perl -w
2
3use strict;
4use IPC::Open2;
5use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
6use FileHandle;
7
8$#ARGV >= 0 || die "usage: autotest.pl config-file\n";
9
10$| = 1;
11
12my %opt;
13
14#default opts
15$opt{"NUM_BUILDS"} = 5;
16$opt{"DEFAULT_BUILD_TYPE"} = "randconfig";
17$opt{"MAKE_CMD"} = "make";
18$opt{"TIMEOUT"} = 50;
19$opt{"TMP_DIR"} = "/tmp/autotest";
20$opt{"SLEEP_TIME"} = 60; # sleep time between tests
Steven Rostedt5c42fc52010-11-02 14:57:01 -040021$opt{"BUILD_NOCLEAN"} = 0;
Steven Rostedt75c3fda72010-11-02 14:57:21 -040022$opt{"REBOOT_ON_ERROR"} = 0;
Steven Rostedt5c42fc52010-11-02 14:57:01 -040023$opt{"POWEROFF_ON_ERROR"} = 0;
24$opt{"POWEROFF_ON_SUCCESS"} = 0;
Steven Rostedt75c3fda72010-11-02 14:57:21 -040025$opt{"BUILD_OPTIONS"} = "";
Steven Rostedt2545eb62010-11-02 15:01:32 -040026
27my $version;
Steven Rostedt2545eb62010-11-02 15:01:32 -040028my $grub_number;
29my $target;
30my $make;
Steven Rostedt5c42fc52010-11-02 14:57:01 -040031my $noclean;
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -040032my $minconfig;
33my $in_bisect = 0;
34my $bisect_bad = "";
Steven Rostedt2545eb62010-11-02 15:01:32 -040035
36sub read_config {
37 my ($config) = @_;
38
39 open(IN, $config) || die "can't read file $config";
40
41 while (<IN>) {
42
43 # ignore blank lines and comments
44 next if (/^\s*$/ || /\s*\#/);
45
46 if (/^\s*(\S+)\s*=\s*(.*?)\s*$/) {
47 my $lvalue = $1;
48 my $rvalue = $2;
49
50 $opt{$lvalue} = $rvalue;
51 }
52 }
53
54 close(IN);
55}
56
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -040057sub logit {
Steven Rostedt2545eb62010-11-02 15:01:32 -040058 if (defined($opt{"LOG_FILE"})) {
59 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
60 print OUT @_;
61 close(OUT);
62 }
63}
64
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -040065sub doprint {
66 print @_;
67 logit @_;
68}
69
Steven Rostedt5c42fc52010-11-02 14:57:01 -040070sub dodie {
71 doprint "CRITICAL FAILURE... ", @_;
72
Steven Rostedt75c3fda72010-11-02 14:57:21 -040073 if ($opt{"REBOOT_ON_ERROR"}) {
74 doprint "REBOOTING\n";
75 `$opt{"POWER_CYCLE"}`;
76
77 } elsif ($opt{"POWEROFF_ON_ERROR"} && defined($opt{"POWER_OFF"})) {
Steven Rostedt5c42fc52010-11-02 14:57:01 -040078 doprint "POWERING OFF\n";
79 `$opt{"POWER_OFF"}`;
80 }
Steven Rostedt75c3fda72010-11-02 14:57:21 -040081
Steven Rostedt5c42fc52010-11-02 14:57:01 -040082 die @_;
83}
84
Steven Rostedt2545eb62010-11-02 15:01:32 -040085sub run_command {
86 my ($command) = @_;
87 my $redirect = "";
88
89 if (defined($opt{"LOG_FILE"})) {
90 $redirect = " >> $opt{LOG_FILE} 2>&1";
91 }
92
93 doprint "$command ... ";
94 `$command $redirect`;
95
96 my $failed = $?;
97
98 if ($failed) {
99 doprint "FAILED!\n";
100 } else {
101 doprint "SUCCESS\n";
102 }
103
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400104 return !$failed;
105}
106
107sub get_grub_index {
108
109 return if ($grub_number >= 0);
110
111 doprint "Find grub menu ... ";
112 $grub_number = -1;
113 open(IN, "ssh $target cat /boot/grub/menu.lst |")
114 or die "unable to get menu.lst";
115 while (<IN>) {
116 if (/^\s*title\s+$opt{GRUB_MENU}\s*$/) {
117 $grub_number++;
118 last;
119 } elsif (/^\s*title\s/) {
120 $grub_number++;
121 }
122 }
123 close(IN);
124
125 die "Could not find '$opt{GRUB_MENU}' in /boot/grub/menu on $opt{MACHINE}"
126 if ($grub_number < 0);
127 doprint "$grub_number\n";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400128}
129
130my $timeout = $opt{"TIMEOUT"};
131
132sub wait_for_input
133{
134 my ($fp, $time) = @_;
135 my $rin;
136 my $ready;
137 my $line;
138 my $ch;
139
140 if (!defined($time)) {
141 $time = $timeout;
142 }
143
144 $rin = '';
145 vec($rin, fileno($fp), 1) = 1;
146 $ready = select($rin, undef, undef, $time);
147
148 $line = "";
149
150 # try to read one char at a time
151 while (sysread $fp, $ch, 1) {
152 $line .= $ch;
153 last if ($ch eq "\n");
154 }
155
156 if (!length($line)) {
157 return undef;
158 }
159
160 return $line;
161}
162
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400163sub reboot_to {
Steven Rostedt2545eb62010-11-02 15:01:32 -0400164 run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'";
165}
166
167sub monitor {
168 my $flags;
169 my $booted = 0;
170 my $bug = 0;
171 my $pid;
172 my $doopen2 = 0;
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400173 my $skip_call_trace = 0;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400174
175 if ($doopen2) {
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400176 $pid = open2(\*IN, \*OUT, $opt{"CONSOLE"});
Steven Rostedt2545eb62010-11-02 15:01:32 -0400177 if ($pid < 0) {
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400178 dodie "Failed to connect to the console";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400179 }
180 } else {
181 $pid = open(IN, "$opt{CONSOLE} |");
182 }
183
184 $flags = fcntl(IN, F_GETFL, 0) or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400185 dodie "Can't get flags for the socket: $!\n";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400186
187 $flags = fcntl(IN, F_SETFL, $flags | O_NONBLOCK) or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400188 dodie "Can't set flags for the socket: $!\n";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400189
190 my $line;
191 my $full_line = "";
192
193 doprint "Wait for monitor to settle down.\n";
194 # read the monitor and wait for the system to calm down
195 do {
196 $line = wait_for_input(\*IN, 5);
197 } while (defined($line));
198
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400199 reboot_to;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400200
201 for (;;) {
202
203 $line = wait_for_input(\*IN);
204
205 last if (!defined($line));
206
207 doprint $line;
208
209 # we are not guaranteed to get a full line
210 $full_line .= $line;
211
212 if ($full_line =~ /login:/) {
213 $booted = 1;
214 }
215
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400216 if ($full_line =~ /\[ backtrace testing \]/) {
217 $skip_call_trace = 1;
218 }
219
Steven Rostedt2545eb62010-11-02 15:01:32 -0400220 if ($full_line =~ /call trace:/i) {
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400221 $bug = 1 if (!$skip_call_trace);
222 }
223
224 if ($full_line =~ /\[ end of backtrace testing \]/) {
225 $skip_call_trace = 0;
226 }
227
228 if ($full_line =~ /Kernel panic -/) {
Steven Rostedt2545eb62010-11-02 15:01:32 -0400229 $bug = 1;
230 }
231
232 if ($line =~ /\n/) {
233 $full_line = "";
234 }
235 }
236
237 doprint "kill child process $pid\n";
238 kill 2, $pid;
239
240 print "closing!\n";
241 close(IN);
242
243 if (!$booted) {
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400244 return 1 if (!$in_bisect);
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400245 dodie "failed - never got a boot prompt.\n";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400246 }
247
248 if ($bug) {
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400249 return 1 if (!$in_bisect);
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400250 dodie "failed - got a bug report\n";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400251 }
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400252
253 return 0;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400254}
255
256sub install {
257
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400258 run_command "scp $opt{OUTPUT_DIR}/$opt{BUILD_TARGET} $target:$opt{TARGET_IMAGE}" or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400259 dodie "failed to copy image";
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400260
261 my $install_mods = 0;
262
263 # should we process modules?
264 $install_mods = 0;
265 open(IN, "$opt{OUTPUT_DIR}/.config") or dodie("Can't read config file");
266 while (<IN>) {
267 if (/CONFIG_MODULES(=y)?/) {
268 $install_mods = 1 if (defined($1));
269 last;
270 }
271 }
272 close(IN);
273
274 if (!$install_mods) {
275 doprint "No modules needed\n";
276 return;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400277 }
278
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400279 run_command "$make INSTALL_MOD_PATH=$opt{TMP_DIR} modules_install" or
280 dodie "Failed to install modules";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400281
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400282 my $modlib = "/lib/modules/$version";
283 my $modtar = "autotest-mods.tar.bz2";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400284
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400285 run_command "ssh $target rm -rf $modlib" or
286 dodie "failed to remove old mods: $modlib";
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400287
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400288 # would be nice if scp -r did not follow symbolic links
289 run_command "cd $opt{TMP_DIR} && tar -cjf $modtar lib/modules/$version" or
290 dodie "making tarball";
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400291
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400292 run_command "scp $opt{TMP_DIR}/$modtar $target:/tmp" or
293 dodie "failed to copy modules";
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400294
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400295 unlink "$opt{TMP_DIR}/$modtar";
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400296
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400297 run_command "ssh $target '(cd / && tar xf /tmp/$modtar)'" or
298 dodie "failed to tar modules";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400299
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400300 run_command "ssh $target rm -f /tmp/$modtar";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400301}
302
303sub build {
304 my ($type) = @_;
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400305 my $defconfig = "";
306 my $append = "";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400307
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400308 if ($type =~ /^useconfig:(.*)/) {
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400309 run_command "cp $1 $opt{OUTPUT_DIR}/.config" or
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400310 dodie "could not copy $1 to .config";
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400311
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400312 $type = "oldconfig";
313 }
314
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400315 # old config can ask questions
316 if ($type eq "oldconfig") {
317 $append = "yes ''|";
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400318
319 # allow for empty configs
320 run_command "touch $opt{OUTPUT_DIR}/.config";
321
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400322 run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp" or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400323 dodie "moving .config";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400324
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400325 if (!$noclean && !run_command "$make mrproper") {
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400326 dodie "make mrproper";
327 }
328
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400329 run_command "mv $opt{OUTPUT_DIR}/config_temp $opt{OUTPUT_DIR}/.config" or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400330 dodie "moving config_temp";
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400331
332 } elsif (!$noclean) {
333 unlink "$opt{OUTPUT_DIR}/.config";
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400334 run_command "$make mrproper" or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400335 dodie "make mrproper";
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400336 }
Steven Rostedt2545eb62010-11-02 15:01:32 -0400337
338 # add something to distinguish this build
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400339 open(OUT, "> $opt{OUTPUT_DIR}/localversion") or dodie("Can't make localversion file");
Steven Rostedt2545eb62010-11-02 15:01:32 -0400340 print OUT "$opt{LOCALVERSION}\n";
341 close(OUT);
342
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400343 if (defined($minconfig)) {
344 $defconfig = "KCONFIG_ALLCONFIG=$minconfig";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400345 }
346
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400347 run_command "$defconfig $append $make $type" or
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400348 dodie "failed make config";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400349
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400350 if (!run_command "$make $opt{BUILD_OPTIONS}") {
351 # bisect may need this to pass
352 return 1 if ($in_bisect);
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400353 dodie "failed build";
Steven Rostedt2545eb62010-11-02 15:01:32 -0400354 }
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400355
356 return 0;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400357}
358
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400359sub reboot {
360 # try to reboot normally
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400361 if (!run_command "ssh $target reboot") {
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400362 # nope? power cycle it.
363 run_command "$opt{POWER_CYCLE}";
364 }
365}
366
367sub halt {
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400368 if (!run_command "ssh $target halt" or defined($opt{"POWER_OFF"})) {
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400369 # nope? the zap it!
370 run_command "$opt{POWER_OFF}";
371 }
372}
373
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400374sub success {
375 my ($i) = @_;
376
377 doprint "\n\n*******************************************\n";
378 doprint "*******************************************\n";
379 doprint "** SUCCESS!!!! **\n";
380 doprint "*******************************************\n";
381 doprint "*******************************************\n";
382
383 if ($i != $opt{"NUM_BUILDS"}) {
384 reboot;
385 doprint "Sleeping $opt{SLEEP_TIME} seconds\n";
386 sleep "$opt{SLEEP_TIME}";
387 }
388}
389
390sub get_version {
391 # get the release name
392 doprint "$make kernelrelease ... ";
393 $version = `$make kernelrelease | tail -1`;
394 chomp($version);
395 doprint "$version\n";
396}
397
398sub run_bisect {
399 my ($type) = @_;
400
401 my $failed;
402 my $result;
403 my $output;
404 my $ret;
405
406
407 if (defined($minconfig)) {
408 $failed = build "useconfig:$minconfig";
409 } else {
410 # ?? no config to use?
411 $failed = build "oldconfig";
412 }
413
414 if ($type ne "build") {
415 dodie "Failed on build" if $failed;
416
417 # Now boot the box
418 get_grub_index;
419 get_version;
420 install;
421 $failed = monitor;
422
423 if ($type ne "boot") {
424 dodie "Failed on boot" if $failed;
425 }
426 }
427
428 if ($failed) {
429 $result = "bad";
430 } else {
431 $result = "good";
432 }
433
434 doprint "git bisect $result ... ";
435 $output = `git bisect $result 2>&1`;
436 $ret = $?;
437
438 logit $output;
439
440 if ($ret) {
441 doprint "FAILED\n";
442 dodie "Failed to git bisect";
443 }
444
445 doprint "SUCCESS\n";
446 if ($output =~ m/^(Bisecting: .*\(roughly \d+ steps?\)) \[([[:xdigit:]]+)\]/) {
447 doprint "$1 [$2]\n";
448 } elsif ($output =~ m/^([[:xdigit:]]+) is the first bad commit/) {
449 $bisect_bad = $1;
450 doprint "Found bad commit... $1\n";
451 return 0;
452 }
453
454
455 return 1;
456}
457
458sub bisect {
459 my ($i) = @_;
460
461 my $result;
462
463 die "BISECT_GOOD[$i] not defined\n" if (!defined($opt{"BISECT_GOOD[$i]"}));
464 die "BISECT_BAD[$i] not defined\n" if (!defined($opt{"BISECT_BAD[$i]"}));
465 die "BISECT_TYPE[$i] not defined\n" if (!defined($opt{"BISECT_TYPE[$i]"}));
466
467 my $good = $opt{"BISECT_GOOD[$i]"};
468 my $bad = $opt{"BISECT_BAD[$i]"};
469 my $type = $opt{"BISECT_TYPE[$i]"};
470
471 $in_bisect = 1;
472
473 run_command "git bisect start" or
474 dodie "could not start bisect";
475
476 run_command "git bisect good $good" or
477 dodie "could not set bisect good to $good";
478
479 run_command "git bisect bad $bad" or
480 dodie "could not set bisect good to $bad";
481
482 do {
483 $result = run_bisect $type;
484 } while ($result);
485
486 run_command "git bisect log" or
487 dodie "could not capture git bisect log";
488
489 run_command "git bisect reset" or
490 dodie "could not reset git bisect";
491
492 doprint "Bad commit was [$bisect_bad]\n";
493
494 $in_bisect = 0;
495
496 success $i;
497}
498
Steven Rostedt2545eb62010-11-02 15:01:32 -0400499read_config $ARGV[0];
500
501# mandatory configs
502die "MACHINE not defined\n" if (!defined($opt{"MACHINE"}));
503die "SSH_USER not defined\n" if (!defined($opt{"SSH_USER"}));
504die "BUILD_DIR not defined\n" if (!defined($opt{"BUILD_DIR"}));
505die "OUTPUT_DIR not defined\n" if (!defined($opt{"OUTPUT_DIR"}));
506die "BUILD_TARGET not defined\n" if (!defined($opt{"BUILD_TARGET"}));
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400507die "TARGET_IMAGE not defined\n" if (!defined($opt{"TARGET_IMAGE"}));
Steven Rostedt2545eb62010-11-02 15:01:32 -0400508die "POWER_CYCLE not defined\n" if (!defined($opt{"POWER_CYCLE"}));
509die "CONSOLE not defined\n" if (!defined($opt{"CONSOLE"}));
510die "LOCALVERSION not defined\n" if (!defined($opt{"LOCALVERSION"}));
511die "GRUB_MENU not defined\n" if (!defined($opt{"GRUB_MENU"}));
512
513chdir $opt{"BUILD_DIR"} || die "can't change directory to $opt{BUILD_DIR}";
514
515$target = "$opt{SSH_USER}\@$opt{MACHINE}";
516
517doprint "\n\nSTARTING AUTOMATED TESTS\n";
518
Steven Rostedt2545eb62010-11-02 15:01:32 -0400519
520$make = "$opt{MAKE_CMD} O=$opt{OUTPUT_DIR}";
521
522# First we need to do is the builds
523for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
524 my $type = "BUILD_TYPE[$i]";
525
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400526 if (defined($opt{"BUILD_NOCLEAN[$i]"}) &&
527 $opt{"BUILD_NOCLEAN[$i]"} != 0) {
528 $noclean = 1;
529 } else {
530 $noclean = $opt{"BUILD_NOCLEAN"};
531 }
532
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400533 if (defined($opt{"MIN_CONFIG[$i]"})) {
534 $minconfig = $opt{"MIN_CONFIG[$i]"};
535 } elsif (defined($opt{"MIN_CONFIG"})) {
536 $minconfig = $opt{"MIN_CONFIG"};
537 } else {
538 undef $minconfig;
539 }
540
Steven Rostedt2545eb62010-11-02 15:01:32 -0400541 if (!defined($opt{$type})) {
542 $opt{$type} = $opt{"DEFAULT_BUILD_TYPE"};
543 }
544
545 doprint "\n\n";
546 doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n";
547
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400548 if ($opt{$type} eq "bisect") {
549 bisect $i;
550 next;
551 }
552
Steven Rostedt2545eb62010-11-02 15:01:32 -0400553 if ($opt{$type} ne "nobuild") {
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400554 build $opt{$type};
Steven Rostedt2545eb62010-11-02 15:01:32 -0400555 }
556
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400557 get_grub_index;
558 get_version;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400559 install;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400560 monitor;
Steven Rostedt5f9b6ce2010-11-02 14:57:33 -0400561 success $i;
Steven Rostedt2545eb62010-11-02 15:01:32 -0400562}
563
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400564if ($opt{"POWEROFF_ON_SUCCESS"}) {
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400565 halt;
566} else {
567 reboot;
Steven Rostedt5c42fc52010-11-02 14:57:01 -0400568}
Steven Rostedt75c3fda72010-11-02 14:57:21 -0400569
Steven Rostedt2545eb62010-11-02 15:01:32 -0400570exit 0;