#!/usr/bin/perl # Expect script to handle a mostly noninteractive second stage. Assumes # that base-config has been preseeded to not ask for anything except for # possibly the root password (if it wasn't preseeded). Ends when the system # is installed and at a login prompt. use strict; use Expect; my $exp = new Expect; #$exp->exp_internal(1); $exp->raw_pty(1); $exp->spawn($ENV{CONSOLECOMMAND}) or die "cannot connect: $!\n"; $exp->expect($ENV{STAGE_2_MAX_TIME}, [ "-re", "Root.*password:" => sub { sleep 1; $exp->send("$ENV{ROOT_PASSWORD}\r"); exp_continue; }], [ "-re", "verify:" => sub { sleep 1; $exp->send("$ENV{ROOT_PASSWORD}\r"); exp_continue; }], [ "-re", "password.*user:" => sub { sleep 1; $exp->send("$ENV{USER_PASSWORD}\r"); exp_continue; }], [ "ogin:" => sub { exit; }], [ "-re", "lo.*gin:" => sub { exit; }], [ "-re", "rting.*[gkx]dm" => sub { exit; }], [ "Unable to mount root fs" => sub { exit 1; }], [ timeout => sub { print STDERR "timeout!\n"; exit 1; }], ); exit;