},
{
step => 'ipconf',
- next_button => '_Install',
html => 'ipconf.htm',
function => \&create_ipconf_view,
},
+ {
+ step => 'ack',
+ html => 'ack.htm',
+ next_button => '_Install',
+ function => \&create_ack_view,
+ },
{
step => 'extract',
next_button => '_Reboot',
# GUI global variables
my ($window, $cmdbox, $inbox, $htmlview);
-my $prev;
+my $prev_btn;
my ($next, $next_fctn, $target_hd);
my ($progress, $progress_status);
my $mailto = 'mail@example.invalid';
my $cmap;
-# Format: screen/function name => settings for that screen
-my $global_configuration = {
-
- # TODO: add all the user-provided options during the install
- # to be able to call them back if necessary
-
- hdsel => {},
- country => {
- country => $country,
- timezone => $timezone,
- keymap => $keymap,
- },
- password => {
- password => $password,
- mailto => $mailto,
- },
- ipconf => {
- hostname => $hostname,
- domain => $domain,
- },
+my $config = {
+ # TODO: add all the user-provided options for previous button
+ country => $country,
+ timezone => $timezone,
+ keymap => $keymap,
+
+ password => $password,
+ mailto => $mailto,
+
+ mngmt_nic => undef,
+ hostname => $hostname,
+ fqdn => undef,
+ ipaddress => undef,
+ netmask => undef,
+ gateway => undef,
};
# parse command line args
my $res = ();
if ($opt_testmode) {
- push @$res, [-1, $opt_testmode, int((-s $opt_testmode)/512), "TESTDISK"];
+ my @disks = split /,/, $opt_testmode;
+
+ for my $disk (@disks) {
+ push @$res, [-1, $disk, int((-s $disk)/512), "TESTDISK"];
+ }
return $res;
}
$fctn = $step_number if !$fctn;
$text = "_Previous" if !$text;
- $prev->set_label ($text);
+ $prev_btn->set_label ($text);
$step_number--;
$steps[$step_number]->{function}();
- $prev->grab_focus ();
+ $prev_btn->grab_focus ();
}
sub set_next {
$cmdbox->pack_end ($next, 0, 0, 10);
- $prev = Gtk3::Button->new ('_Previous');
- $prev->signal_connect (clicked => sub { $last_display_change = 0; &prev_function (); });
- $cmdbox->pack_end ($prev, 0, 0, 10);
+ $prev_btn = Gtk3::Button->new ('_Previous');
+ $prev_btn->signal_connect (clicked => sub { $last_display_change = 0; &prev_function (); });
+ $cmdbox->pack_end ($prev_btn, 0, 0, 10);
my $abort = Gtk3::Button->new ('_Abort');
my $vbox2 = Gtk3::VBox->new (0, 0);
$hbox->add ($vbox2);
+ my $ipaddr_text = $config->{ipaddress} // "192.168.100.2";
my $ipbox;
($ipbox, $ipconf_entry_addr) =
- create_text_input ("192.168.100.2", 'IP Address:');
+ create_text_input ($ipaddr_text, 'IP Address:');
+ my $netmask_text = $config->{netmask} // "255.255.255.0";
my $maskbox;
($maskbox, $ipconf_entry_mask) =
- create_text_input ("255.255.255.0", 'Netmask:');
+ create_text_input ($netmask_text, 'Netmask:');
my $device_cb = Gtk3::ComboBoxText->new();
$device_cb->set_active(0);
};
my $device_active_map = {};
+ my $device_active_reverse_map = {};
my $device_change_handler = sub {
my $current = shift;
$ipconf->{selected} = $device_active_map->{$current->get_active()};
my $iface = $ipconf->{ifaces}->{$ipconf->{selected}};
+ $config->{mngmt_nic} = $iface->{name};
$ipconf_entry_addr->set_text($iface->{inet}->{addr} || $iface->{inet6}->{addr})
if $iface->{inet}->{addr} || $iface->{inet6}->{addr};
$ipconf_entry_mask->set_text($iface->{inet}->{mask} || $iface->{inet6}->{mask})
my $i = 0;
foreach my $index (sort keys %{$ipconf->{ifaces}}) {
$device_cb->append_text(&$get_device_desc($ipconf->{ifaces}->{$index}));
- $device_active_map->{$i} = $index;
+ $device_active_map->{$i} = $index;
+ $device_active_reverse_map->{$ipconf->{ifaces}->{$index}->{name}} = $i;
if ($ipconf_first_view && $index == $ipconf->{default}) {
$device_cb->set_active($i);
&$device_change_handler($device_cb);
$i++;
}
- $device_cb->set_active(0)
- if !($ipconf->{selected});
+ if (my $nic = $config->{mngmt_nic}) {
+ $device_cb->set_active($device_active_reverse_map->{$nic} // 0);
+ } else {
+ $device_cb->set_active(0);
+ }
my $devicebox = Gtk3::HBox->new (0, 0);
my $label = Gtk3::Label->new ("Management Interface:");
$vbox2->pack_start ($devicebox, 0, 0, 2);
- my $hn = $ipconf->{domain} ?
- "$setup->{product}.$ipconf->{domain}" : "$setup->{product}.example.invalid";
+ my $hn = $config->{fqdn} // "$setup->{product}." . ($ipconf->{domain} // "example.invalid");
my ($hostbox, $hostentry) =
create_text_input ($hn, 'Hostname (FQDN):');
$vbox2->pack_start ($maskbox, 0, 0, 2);
- $gateway = $ipconf->{gateway} || '192.168.100.1';
+ $gateway = $config->{gateway} // $ipconf->{gateway} || '192.168.100.1';
my $gwbox;
($gwbox, $ipconf_entry_gw) =
$vbox2->pack_start ($gwbox, 0, 0, 2);
- $dnsserver = $ipconf->{dnsserver} || $gateway;
+ $dnsserver = $config->{dnsserver} // $ipconf->{dnsserver} || $gateway;
my $dnsbox;
($dnsbox, $ipconf_entry_dns) =
$text =~ s/^\s+//;
$text =~ s/\s+$//;
+ $config->{fqdn} = $text;
+
my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
# Debian does not support purely numeric hostnames
$ipconf_entry_addr->grab_focus();
return;
}
+ $config->{ipaddress} = $ipaddress;
$text = $ipconf_entry_mask->get_text();
$text =~ s/^\s+//;
$ipconf_entry_mask->grab_focus();
return;
}
+ $config->{netmask} = $netmask;
$text = $ipconf_entry_gw->get_text();
$text =~ s/^\s+//;
$ipconf_entry_gw->grab_focus();
return;
}
+ $config->{gateway} = $gateway;
$text = $ipconf_entry_dns->get_text();
$text =~ s/^\s+//;
$ipconf_entry_dns->grab_focus();
return;
}
+ $config->{dnsserver} = $dnsserver;
#print "TEST $ipaddress $netmask $gateway $dnsserver\n";
$step_number++;
- create_extract_view();
+ create_ack_view();
});
$hostentry->grab_focus();
}
+sub create_ack_view {
+
+ cleanup_view();
+
+ my $ack_template = "${proxmox_libdir}/html/ack_template.htm";
+ my $ack_html = "${proxmox_libdir}/html/$steps[$step_number]->{html}";
+ my $html_data = file_get_contents($ack_template);
+
+ my %config_values = (
+ __target_hd__ => $target_hd,
+ __target_fs__ => $config_options->{filesys},
+ __country__ => $country,
+ __timezone__ => $timezone,
+ __keymap__ => $keymap,
+ __mailto__ => $mailto,
+ __interface__ => $ipconf->{ifaces}->{$ipconf->{selected}}->{name},
+ __hostname__ => $hostname,
+ __ip__ => $ipaddress,
+ __netmask__ => $netmask,
+ __gateway__ => $gateway,
+ __dnsserver__ => $dnsserver,
+ );
+
+ while ( my ($k, $v) = each %config_values) {
+ $html_data =~ s/$k/$v/g;
+ }
+
+ write_config($html_data, $ack_html);
+
+ display_html();
+
+ set_next(undef, sub {
+ $step_number++;
+ create_extract_view();
+ });
+}
+
sub get_device_desc {
my ($devname, $size, $model) = @_;
sub create_hdsel_view {
- $prev->set_sensitive(1); # enable previous button at this point
+ $prev_btn->set_sensitive(1); # enable previous button at this point
cleanup_view ();
sub create_intro_view {
- $prev->set_sensitive(0);
+ $prev_btn->set_sensitive(0);
cleanup_view();