my $file;
my $EOF;
my $last_fn = '';
-my ($modules, $variables, $generated, $continuation);
+my ($modules, $variables, $generated, $continuation) = ([], {}, []);
my $skip_reading = defined($on_opt) || defined($off_opt);
while (!$skip_reading && ($_ = <>)) {
if ($ARGV ne $last_fn) { # New script
if (defined $builddir) {
chdir($builddir) or die "Can't change directory to $builddir: $!";
print "novaboot: Entering directory `$builddir'\n";
+} else {
+ $builddir = $invocation_dir;
}
## File generation phase
$exp->expect(20,
[qr/Hit any key to stop autoboot:/, sub { $exp->send("\n"); exp_continue; }],
$uboot_prompt) || die "No uBoot prompt deteceted";
- while (@uboot_init) {
- my $cmd = shift @uboot_init;
+ foreach my $cmd (@uboot_init) {
+ if ($cmd =~ /\$NB_MYIP/) {
+ my $ip = (grep /inet /, `ip addr show eth0`)[0] || die "Problem determining our IP address";
+ $ip =~ s/\s*inet ([0-9.]*).*/$1/;
+ $cmd =~ s/\$NB_MYIP/$ip/g;
+ }
+ chomp($cmd);
$exp->send("$cmd\n");
$exp->expect(10, $uboot_prompt) || die "uBoot prompt timeout";
}
$exp->send("tftp $kern_addr $kbin\n");
$exp->expect(10,
- [qr/#/, sub { exp_continue; }],
- $uboot_prompt) || die "Kernel load failed";
+ [qr/##/, sub { exp_continue; }],
+ $uboot_prompt) || die "No U-Boot prompt deteceted";
if (defined $dtb) {
$dtb_addr = '7f0000';
$exp->send("tftp $dtb_addr $dtb\n");
booting them. This option can be given multiple times. After sending
commands from each option novaboot waits for U-Boot I<prompt>.
+If the command contains string I<$NB_MYIP> then this string is
+replaced by IPv4 address of eth0 interface.
+
=back
=head2 Target interaction phase