From 1bdcb67c196de95d241e615e028e8beb00399500 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Mon, 21 Oct 2013 01:47:50 +0200 Subject: [PATCH] Remove $iprelay configuration variable Also improve --on/--off handling. --- README.md | 22 ++++++---------------- novaboot | 38 +++++++++++--------------------------- 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 1f878c8..fc3ed73 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ configuration specified in the _script_. bootloaders are GRUB, GRUB2 and Pulsar) and copy it with all other files needed for booting to another, perhaps remote, location. - ./script --server --iprelay + ./script --server --iprelay=192.168.1.2 This command copies files to a TFTP server specified in the configuration file and uses TCP/IP-controlled relay to reset the test @@ -277,22 +277,17 @@ to a particular location, e.g. to a TFTP boot server or to the ## Target power-on and reset phase -- \--iprelay\[=addr or cmd\] +- \--iprelay=_addr\[:port\]_ - If no _cmd_ is given, use IP relay to reset the machine and to get - the serial output. The IP address of the relay is given by _addr_ - parameter if specified or by $iprelay\_addr variable in the - configuration file. - - If _cmd_ is one of "on" or "off", the IP relay is used to press power - button for a short (in case of "on") or long (in case of "off") time. - Then, novaboot exits. + Use IP relay to reset the machine and to get the serial output. The IP + address of the relay is given by _addr_ parameter. Note: This option is expected to work with HWG-ER02a IP relays. - \--on, --off - Synonym for --iprelay=on/off. + Switch on/off the target machine. Currently works only with + __\--iprelay__. - \-Q, --qemu=_qemu-binary_ @@ -458,11 +453,6 @@ override the environment variables. Defining this variable has the same meaning as __\--bender__ option. -- NOVABOOT\_IPRELAY - - The IP address (and optionally the port) of the IP relay. This - overrides $iprelay\_addr variable from the configuration file. - # AUTHORS Michal Sojka diff --git a/novaboot b/novaboot index a48f192..7d55e9d 100755 --- a/novaboot +++ b/novaboot @@ -40,7 +40,6 @@ chomp(my $gittop = `git rev-parse --show-toplevel 2>/dev/null`); $CFG::hypervisor = ""; $CFG::hypervisor_params = "serial"; $CFG::genisoimage = "genisoimage"; -$CFG::iprelay_addr = '141.76.48.80:2324'; #'141.76.48.252'; $CFG::qemu = 'qemu'; @CFG::chainloaders = (); #('bin/boot/bender promisc'); # TODO: convert to option $CFG::pulsar_root = ''; # TODO: convert to option @@ -110,7 +109,7 @@ my %opt_spec; "grub-prefix=s" => \$grub_prefix, "grub2:s" => \$grub2_config, "grub2-prolog=s" => \$grub2_prolog, - "iprelay:s" => \$iprelay, + "iprelay=s" => \$iprelay, "iso|i:s" => \$iso_image, "name=s" => \$config_name_opt, "no-file-gen" => \$no_file_gen, @@ -138,9 +137,6 @@ pod2usage(-exitstatus => 0, -verbose => 2) if $man; ### Sanitize configuration -$CFG::iprelay_addr = $ENV{'NOVABOOT_IPRELAY'} if $ENV{'NOVABOOT_IPRELAY'}; -if ($iprelay && $iprelay ne "on" && $iprelay ne "off") { $CFG::iprelay_addr = $iprelay; } - if (defined $config_name_opt && scalar(@ARGV) > 1) { die "You cannot use --name with multiple scripts"; } if ($qemu) { $CFG::qemu = $qemu; } @@ -180,9 +176,6 @@ if (defined $grub2_config) { $grub2_config ||= "grub.cfg"; } -if ($on_opt) { $iprelay="on"; } -if ($off_opt) { $iprelay="off"; } - ## Parse the novaboot script(s) my @scripts; my $file; @@ -381,7 +374,7 @@ if (exists $variables->{WVDESC}) { my $IPRELAY; if (defined $iprelay) { - $CFG::iprelay_addr =~ /([.0-9]+)(:([0-9]+))?/; + $iprelay =~ /([.0-9]+)(:([0-9]+))?/; my $addr = $1; my $port = $3 || 23; my $paddr = sockaddr_in($port, inet_aton($addr)); @@ -459,11 +452,12 @@ if (defined $iprelay) { } } -if ($iprelay && ($iprelay eq "on" || $iprelay eq "off")) { +if ($iprelay && (defined $on_opt || defined $off_opt)) { relay(1, 1); # Press power button - if ($iprelay eq "on") { + if (defined $on_opt) { usleep(100000); # Short press } else { + print "novaboot: Switching the target off...\n"; usleep(6000000); # Long press to switch off } print $IPRELAY relay(1, 0); @@ -749,7 +743,7 @@ Create a bootloader configuration file (currently supported bootloaders are GRUB, GRUB2 and Pulsar) and copy it with all other files needed for booting to another, perhaps remote, location. - ./script --server --iprelay + ./script --server --iprelay=192.168.1.2 This command copies files to a TFTP server specified in the configuration file and uses TCP/IP-controlled relay to reset the test @@ -1018,22 +1012,17 @@ itself. =over 8 -=item --iprelay[=addr or cmd] - -If no I is given, use IP relay to reset the machine and to get -the serial output. The IP address of the relay is given by I -parameter if specified or by $iprelay_addr variable in the -configuration file. +=item --iprelay=I -If I is one of "on" or "off", the IP relay is used to press power -button for a short (in case of "on") or long (in case of "off") time. -Then, novaboot exits. +Use IP relay to reset the machine and to get the serial output. The IP +address of the relay is given by I parameter. Note: This option is expected to work with HWG-ER02a IP relays. =item --on, --off -Synonym for --iprelay=on/off. +Switch on/off the target machine. Currently works only with +B<--iprelay>. =item -Q, --qemu=I @@ -1216,11 +1205,6 @@ one(s). Defining this variable has the same meaning as B<--bender> option. -=item NOVABOOT_IPRELAY - -The IP address (and optionally the port) of the IP relay. This -overrides $iprelay_addr variable from the configuration file. - =back =head1 AUTHORS -- 2.39.2