12 use POSIX
":sys_wait_h";
16 Proxmox
::Log
::init
("/tmp/install.log");
18 { # NOTE: order is important here
21 'test-image|t=s' => \
$test_image
22 ) or die "usage error\n";
24 Proxmox
::Install
::ISOEnv
::set_test_image
($test_image) if $test_image;
27 use Proxmox
::Install
::ISOEnv
;
28 use Proxmox
::Install
::RunEnv
;
30 # init singletons TODO: avoid all global initialization, use single "main" method
31 my $iso_env = Proxmox
::Install
::ISOEnv
::get
();
34 use Proxmox
::Install
::Config
;
36 use Proxmox
::Sys
::Block
qw(get_cached_disks);
37 use Proxmox
::Sys
::Command
qw(syscmd);
38 use Proxmox
::Sys
::File
qw(file_read_all file_write_all);
39 use Proxmox
::Sys
::Net
qw(parse_ip_address parse_ip_mask);
42 if (!$ENV{G_SLICE
} || $ENV{G_SLICE
} ne "always-malloc") {
43 die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
46 my $step_number = 0; # Init number for global function list
51 html
=> 'license.htm',
52 next_button
=> 'I a_gree',
53 function
=> \
&create_intro_view
,
58 function
=> \
&create_hdsel_view
,
62 html
=> 'country.htm',
63 function
=> \
&create_country_view
,
68 function
=> \
&create_password_view
,
73 function
=> \
&create_ipconf_view
,
78 next_button
=> '_Install',
79 function
=> \
&create_ack_view
,
83 next_button
=> '_Reboot',
84 function
=> \
&create_extract_view
,
88 # GUI global variables
91 my $target_hds; # only for the summary view
96 Gtk3-
>main_quit() if Gtk3-
>main_level() > 0;
98 # reap left over zombie processes
99 while ((my $child = waitpid(-1, POSIX
::WNOHANG
)) > 0) {
100 print STDERR
"reaped child $child\n";
106 my ($text, $fctn) = @_;
108 $fctn = $step_number if !$fctn;
109 $text = "_Previous" if !$text;
110 $gtk_state->{prev_btn
}->set_label($text);
113 $steps[$step_number]->{function
}();
115 $gtk_state->{prev_btn
}->grab_focus();
119 my ($text, $fctn) = @_;
121 $gtk_state->{next_btn_callback
} = $fctn;
122 my $step = $steps[$step_number];
123 $text //= $steps[$step_number]->{next_button
} // '_Next';
124 $gtk_state->{next_btn
}->set_label($text);
126 $gtk_state->{next_btn
}->grab_focus();
129 sub create_main_window
{
131 my $window = Gtk3
::Window-
>new();
132 $window->set_default_size(1024, 768);
133 $window->signal_connect(map => sub { $window->set_resizable(0); });
134 $window->fullscreen() if !is_test_mode
();
135 $window->set_decorated(0) if !is_test_mode
();
136 $window->signal_connect(destroy
=> sub { Gtk3-
>main_quit(); });
138 my $vbox = Gtk3
::Box-
>new('vertical', 0);
140 my $logofn = "$iso_env->{product}-banner.png";
141 my $proxmox_libdir = $iso_env->{locations
}->{lib
};
142 my $image = Gtk3
::Image-
>new_from_file("${proxmox_libdir}/$logofn");
144 my $provider = Gtk3
::CssProvider-
>new();
145 my $theming = "* {\nbackground: #171717;\n}";
146 $provider->load_from_data ([map ord, split //, $theming]);
147 my $context = $image->get_style_context();
148 $context->add_provider($provider, 600);
150 $vbox->pack_start($image, 0, 0, 0);
152 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
153 $vbox->pack_start($hbox, 1, 1, 0);
155 # my $f1 = Gtk3::Frame->new ('test');
156 # $f1->set_shadow_type ('none');
157 # $hbox->pack_start ($f1, 1, 1, 0);
159 my $sep1 = Gtk3
::Separator-
>new('horizontal');
160 $vbox->pack_start($sep1, 0, 0, 0);
162 my $cmdbox = Gtk3
::Box-
>new('horizontal', 0);
163 $vbox->pack_start($cmdbox, 0, 0, 10);
165 my $next_btn = Gtk3
::Button-
>new('_Next');
166 $next_btn->signal_connect(clicked
=> sub {
167 Proxmox
::Install
::reset_last_display_change
();
168 $gtk_state->{next_btn_callback
}->();
170 $cmdbox->pack_end($next_btn, 0, 0, 10);
172 my $prev_btn = Gtk3
::Button-
>new('_Previous');
173 $prev_btn->signal_connect(clicked
=> sub {
174 Proxmox
::Install
::reset_last_display_change
();
177 $cmdbox->pack_end($prev_btn, 0, 0, 10);
180 my $abort = Gtk3
::Button-
>new('_Abort');
181 $abort->set_can_focus(0);
182 $cmdbox->pack_start($abort, 0, 0, 10);
183 $abort->signal_connect(clicked
=> sub {
184 my $msg = 'Abort Installation';
185 my $secondary_text = 'Are you sure you want to abort the installation?';
186 my $dialog = Gtk3
::MessageDialog-
>new($window, 'modal', 'question', 'yes-no', $msg);
187 $dialog->format_secondary_text($secondary_text);
188 $dialog->signal_connect(response
=> sub {
189 my ($dialog, $response) = @_;
192 app_quit
(-1) if $response eq 'yes';
197 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
200 my $html_view = Gtk3
::WebKit2
::WebView-
>new();
201 $html_view->set_hexpand(1);
202 my $scrolls = Gtk3
::ScrolledWindow-
>new();
203 $scrolls->add($html_view);
205 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
206 $hbox2->pack_start($scrolls, 1, 1, 0);
208 $vbox2->pack_start($hbox2, 1, 1, 0);
210 my $vbox3 = Gtk3
::Box-
>new('vertical', 0);
211 $vbox2->pack_start($vbox3, 0, 0, 0);
213 my $sep2 = Gtk3
::Separator-
>new('horizontal');
214 $vbox3->pack_start($sep2, 0, 0, 0);
216 my $inbox = Gtk3
::Box-
>new('horizontal', 0);
217 $vbox3->pack_start($inbox, 0, 0, 0);
221 $gtk_state->{window
} = $window;
222 $gtk_state->{html_view
} = $html_view;
223 $gtk_state->{inbox
} = $inbox;
224 $gtk_state->{prev_btn
} = $prev_btn;
225 $gtk_state->{next_btn
} = $next_btn;
226 $gtk_state->{progress_bar
} = Gtk3
::ProgressBar-
>new();
227 $gtk_state->{progress_status
} = Gtk3
::Label-
>new('');
228 $gtk_state->{abort_btn
} = $abort;
229 $gtk_state->{disk_selection
} = {};
231 Proxmox
::UI
::init_gtk
($gtk_state, $iso_env);
238 $gtk_state->{inbox
}->foreach(sub {
240 $gtk_state->{inbox
}->remove ($child);
244 # fixme: newer GTK3 has special properties to handle numbers with Entry
245 # only allow floating point numbers with Gtk3::Entry
248 my ($entry, $event) = @_;
250 return check_number
($entry, $event, 1);
254 my ($entry, $event) = @_;
256 return check_number
($entry, $event, 0);
260 my ($entry, $event, $float) = @_;
262 my $val = $event->get_keyval;
264 if (($float && $val == ord '.') ||
265 $val == Gtk3
::Gdk
::KEY_ISO_Left_Tab
||
266 $val == Gtk3
::Gdk
::KEY_Shift_L
||
267 $val == Gtk3
::Gdk
::KEY_Tab
||
268 $val == Gtk3
::Gdk
::KEY_Left
||
269 $val == Gtk3
::Gdk
::KEY_Right
||
270 $val == Gtk3
::Gdk
::KEY_BackSpace
||
271 $val == Gtk3
::Gdk
::KEY_Delete
||
272 ($val >= ord '0' && $val <= ord '9') ||
273 ($val >= Gtk3
::Gdk
::KEY_KP_0
&&
274 $val <= Gtk3
::Gdk
::KEY_KP_9
)) {
281 sub create_text_input
{
282 my ($default, $text) = @_;
284 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
286 my $label = Gtk3
::Label-
>new($text);
287 $label->set_size_request(150, -1);
288 $label->set_xalign(1.0);
289 $hbox->pack_start($label, 0, 0, 10);
290 my $e1 = Gtk3
::Entry-
>new();
291 $e1->set_width_chars(35);
292 $hbox->pack_start($e1, 0, 0, 0);
293 $e1->set_text($default);
297 sub create_cidr_inputs
{
300 my ($default_ip, $default_mask) = split('/', $cidr);
302 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
304 my $label = Gtk3
::Label-
>new('IP Address (CIDR)');
305 $label->set_size_request(150, -1);
306 $label->set_xalign(1.0);
307 $hbox->pack_start($label, 0, 0, 10);
309 my $ip_el = Gtk3
::Entry-
>new();
310 $ip_el->set_width_chars(28);
311 $hbox->pack_start($ip_el, 0, 0, 0);
312 $ip_el->set_text($default_ip);
314 $label = Gtk3
::Label-
>new('/');
315 $label->set_size_request(10, -1);
316 $hbox->pack_start($label, 0, 0, 2);
318 my $cidr_el = Gtk3
::Entry-
>new();
319 $cidr_el->set_width_chars(3);
320 $hbox->pack_start($cidr_el, 0, 0, 0);
321 $cidr_el->set_text($default_mask);
323 return ($hbox, $ip_el, $cidr_el);
326 my $ipconf_first_view = 1;
328 sub create_ipconf_view
{
331 Proxmox
::UI
::display_html
('ipconf.htm');
333 my $vcontainer = Gtk3
::Box-
>new('vertical', 0);
334 $gtk_state->{inbox
}->pack_start($vcontainer, 1, 0, 0);
335 my $hcontainer = Gtk3
::Box-
>new('horizontal', 0);
336 $vcontainer->pack_start($hcontainer, 0, 0, 10);
337 my $vbox = Gtk3
::Box-
>new('vertical', 0);
338 $hcontainer->add($vbox);
340 my $cidr = Proxmox
::Install
::Config
::get_cidr
() // '192.168.100.2/24';
342 my ($cidr_box, $ipconf_entry_addr, $ipconf_entry_mask) = create_cidr_inputs
($cidr);
344 my $device_model = Gtk3
::ListStore-
>new('Glib::String', 'Glib::String');
345 my $device_cb = Gtk3
::ComboBox-
>new_with_model($device_model);
346 $device_cb->set_active(0);
347 $device_cb->set_visible(1);
349 my $icon_cell = Gtk3
::CellRendererText-
>new();
350 $device_cb->pack_start($icon_cell, 0);
351 $device_cb->add_attribute($icon_cell, 'text', 0);
352 $icon_cell->set_property('foreground', 'green');
354 my $cell = Gtk3
::CellRendererText-
>new();
355 $device_cb->pack_start($cell, 0);
356 $device_cb->add_attribute($cell, 'text', 1);
358 my $get_device_desc = sub {
360 return "$iface->{name} - $iface->{mac} ($iface->{driver})";
363 my $run_env = Proxmox
::Install
::RunEnv
::get
();
364 my $ipconf = $run_env->{ipconf
};
366 my ($device_active_map, $device_active_reverse_map) = ({}, {});
368 my $device_change_handler = sub {
371 my $new = $device_active_map->{$current->get_active()};
372 my $selected = Proxmox
::Install
::Config
::get_mngmt_nic_id
();
373 return if defined($selected) && $new eq $selected;
375 Proxmox
::Install
::Config
::set_mngmt_nic_id
($new);
376 my $iface = $ipconf->{ifaces
}->{$new};
377 Proxmox
::Install
::Config
::set_mngmt_nic
($iface->{name
});
378 $ipconf_entry_addr->set_text($iface->{inet
}->{addr
} || $iface->{inet6
}->{addr
})
379 if $iface->{inet
}->{addr
} || $iface->{inet6
}->{addr
};
380 $ipconf_entry_mask->set_text($iface->{inet
}->{prefix
} || $iface->{inet6
}->{prefix
})
381 if $iface->{inet
}->{prefix
} || $iface->{inet6
}->{prefix
};
385 for my $index (sort keys $ipconf->{ifaces
}->%*) {
386 my $iface = $ipconf->{ifaces
}->{$index};
387 my $iter = $device_model->append();
388 my $symbol = "$iface->{state}" eq "UP" ?
"\x{25CF}" : ' ';
389 $device_model->set($iter,
391 1 => $get_device_desc->($iface),
393 $device_active_map->{$i} = $index;
394 $device_active_reverse_map->{$iface->{name
}} = $i;
395 if ($ipconf_first_view && $index == $ipconf->{default}) {
396 $device_cb->set_active($i);
397 &$device_change_handler($device_cb);
398 $ipconf_first_view = 0;
400 $device_cb->signal_connect('changed' => $device_change_handler);
404 if (my $nic = Proxmox
::Install
::Config
::get_mngmt_nic
()) {
405 $device_cb->set_active($device_active_reverse_map->{$nic} // 0);
407 $device_cb->set_active(0);
410 my $devicebox = Gtk3
::Box-
>new('horizontal', 0);
411 my $label = Gtk3
::Label-
>new("Management Interface:");
412 $label->set_size_request(150, -1);
413 $label->set_xalign(1.0);
414 $devicebox->pack_start($label, 0, 0, 10);
415 $devicebox->pack_start($device_cb, 0, 0, 0);
417 $vbox->pack_start($devicebox, 0, 0, 2);
419 my $fqdn = Proxmox
::Install
::Config
::get_fqdn
();
420 my $hostname = $run_env->{network
}->{hostname
} || $iso_env->{product
};
421 my $domain = $ipconf->{domain
} || "example.invalid";
422 $fqdn //= "$hostname.$domain";
424 my ($hostbox, $hostentry) = create_text_input
($fqdn, 'Hostname (FQDN):');
425 $vbox->pack_start($hostbox, 0, 0, 2);
427 $vbox->pack_start($cidr_box, 0, 0, 2);
429 my $cfg_gateway = Proxmox
::Install
::Config
::get_gateway
();
430 my $gateway = $cfg_gateway // $ipconf->{gateway
} || '192.168.100.1';
432 my ($gwbox, $ipconf_entry_gw) = create_text_input
($gateway, 'Gateway:');
433 $vbox->pack_start($gwbox, 0, 0, 2);
435 my $cfg_dns = Proxmox
::Install
::Config
::get_dns
();
436 my $dnsserver = $cfg_dns // $ipconf->{dnsserver
} || $gateway;
438 my ($dnsbox, $ipconf_entry_dns) = create_text_input
($dnsserver, 'DNS Server:');
440 $vbox->pack_start($dnsbox, 0, 0, 0);
442 $gtk_state->{inbox
}->show_all;
443 set_next
(undef, sub {
445 my $text = $hostentry->get_text();
449 # Debian does not support purely numeric hostnames
450 if ($text && $text =~ /^[0-9]+(?:\.|$)/) {
451 Proxmox
::UI
::message
("Purely numeric hostnames are not allowed.");
452 $hostentry->grab_focus();
457 && $text =~ m/^${Proxmox::Sys::Net::FQDN_RE}$/
458 && $text !~ m/.example.invalid$/
459 && $text =~ m/^([^\.]+)\.(\S+)$/
461 Proxmox
::Install
::Config
::set_hostname
($1);
462 Proxmox
::Install
::Config
::set_domain
($2);
464 Proxmox
::UI
::message
("Hostname does not look like a fully qualified domain name.");
465 $hostentry->grab_focus();
470 $text = $ipconf_entry_addr->get_text();
471 my ($ipaddress, $ipversion) = parse_ip_address
($text);
472 if (!defined($ipaddress)) {
473 Proxmox
::UI
::message
("IP address is not valid.");
474 $ipconf_entry_addr->grab_focus();
478 $text = $ipconf_entry_mask->get_text();
479 my $netmask = parse_ip_mask
($text, $ipversion);
480 if (!defined($netmask)) {
481 Proxmox
::UI
::message
("Netmask is not valid.");
482 $ipconf_entry_mask->grab_focus();
485 Proxmox
::Install
::Config
::set_cidr
("$ipaddress/$netmask");
487 $text = $ipconf_entry_gw->get_text();
488 my ($gateway_ip, $gateway_ip_version) = parse_ip_address
($text);
489 if (!defined($gateway_ip) || $gateway_ip_version != $ipversion) {
490 my $msg = defined($gateway_ip)
491 ?
"Gateway and host IP version must not differ (IPv$gateway_ip_version != IPv$ipversion)."
492 : "Gateway is not valid.";
493 Proxmox
::UI
::message
($msg);
494 $ipconf_entry_gw->grab_focus();
497 Proxmox
::Install
::Config
::set_gateway
($gateway_ip);
499 $text = $ipconf_entry_dns->get_text();
500 my ($dns_ip, $dns_ip_version) = parse_ip_address
($text);
501 if (!defined($dns_ip) || $dns_ip_version != $ipversion) {
502 my $msg = defined($dns_ip)
503 ?
"DNS and host IP version must not differ (IPv$dns_ip_version != IPv$ipversion)."
504 : "DNS IP is not valid.";
505 Proxmox
::UI
::message
($msg);
506 $ipconf_entry_dns->grab_focus();
509 Proxmox
::Install
::Config
::set_dns
($dns_ip);
511 #print STDERR "TEST $ipaddress/$netmask $gateway_ip $dns_ip\n";
517 $hostentry->grab_focus();
520 sub create_ack_view
{
524 my $vbox = Gtk3
::Box-
>new('vertical', 0);
525 $gtk_state->{inbox
}->pack_start($vbox, 1, 0, 0);
527 my $reboot_checkbox = Gtk3
::CheckButton-
>new('Automatically reboot after successful installation');
528 $reboot_checkbox->set_active(1);
529 $reboot_checkbox->signal_connect ("toggled" => sub {
531 Proxmox
::Install
::Config
::set_autoreboot
(!!$cb->get_active());
533 $vbox->pack_start($reboot_checkbox, 0, 0, 2);
535 my $proxmox_libdir = $iso_env->{locations
}->{lib
};
536 my $ack_template = "${proxmox_libdir}/html/ack_template.htm";
537 my $ack_html = "${proxmox_libdir}/html/$iso_env->{product}/$steps[$step_number]->{html}";
538 my $html_data = file_read_all
($ack_template);
540 my $country = Proxmox
::Install
::Config
::get_country
();
542 my %config_values = (
543 __target_hd__
=> join(' | ', $target_hds->@*),
544 __target_fs__
=> Proxmox
::Install
::Config
::get_filesys
(),
545 __country__
=> $iso_env->{locales
}->{country
}->{$country}->{name
},
546 __timezone__
=> Proxmox
::Install
::Config
::get_timezone
(),
547 __keymap__
=> Proxmox
::Install
::Config
::get_keymap
(),
548 __mailto__
=> Proxmox
::Install
::Config
::get_mailto
(),
549 __interface__
=> Proxmox
::Install
::Config
::get_mngmt_nic
(),
550 __hostname__
=> Proxmox
::Install
::Config
::get_hostname
(),
551 __cidr__
=> Proxmox
::Install
::Config
::get_cidr
(),
552 __gateway__
=> Proxmox
::Install
::Config
::get_gateway
(),
553 __dnsserver__
=> Proxmox
::Install
::Config
::get_dns
(),
556 while (my ($k, $v) = each %config_values) {
557 $html_data =~ s/$k/$v/g;
561 my $config = Proxmox
::Install
::Config
::get
();
563 "$iso_env->{locations}->{run}/config-ack.json",
564 to_json
($config, { utf8
=> 1, canonical
=> 1 }) ."\n",
567 warn "failed to write config-for-ack - $@" if $@;
569 file_write_all
($ack_html, $html_data);
571 Proxmox
::UI
::display_html
('ack.htm');
573 $gtk_state->{inbox
}->show_all;
575 set_next
(undef, sub {
577 create_extract_view
();
581 sub get_device_desc
{
582 my ($devname, $size, $model) = @_;
584 if ($size && ($size > 0)) {
585 $size = int($size/2048); # size in MiB, from 512B "sectors"
587 my $text = "$devname (";
589 $size = $size/1024; # size in GiB
591 $size = $size/1024; # size in TiB
592 $text .= sprintf("%.2f", $size) . "TiB";
594 $text .= sprintf("%.2f", $size) . "GiB";
597 $text .= "${size}MiB";
600 $text .= ", $model" if $model;
612 my ($cb, $kmap) = @_;
617 my $kmaphash = $iso_env->{locales
}->{kmaphash
};
618 foreach my $layout (sort keys %$kmaphash) {
619 $def = $i if $kmaphash->{$layout} eq 'en-us';
620 $ind = $i if $kmap && $kmaphash->{$layout} eq $kmap;
624 my $val = $ind || $def || 0;
626 if (!defined($kmap)) {
627 $last_layout //= $val;
628 } elsif (!defined($country_layout) || $country_layout != $val) {
629 $last_layout = $country_layout = $val;
631 $cb->set_active($last_layout);
635 sub update_zonelist
{
638 my $sel = Proxmox
::Install
::Config
::get_timezone
(); # initial default
640 $sel = $lastzonecb->get_active_text();
641 $box->remove($lastzonecb);
644 my $cb = $lastzonecb = Gtk3
::ComboBoxText-
>new();
645 $cb->set_size_request(200, -1);
646 $cb->signal_connect('changed' => sub {
647 my $timezone = $cb->get_active_text();
648 Proxmox
::Install
::Config
::set_timezone
($timezone);
651 my ($cczones, $zones) = $iso_env->{locales
}->@{'cczones', 'zones'};
652 my @available_zones = $cc && defined($cczones->{$cc}) ?
keys %{$cczones->{$cc}} : keys %$zones;
654 my ($i, $selected_index) = (0, undef);
655 for my $zone (sort @available_zones) {
656 $selected_index = $i if $sel && $zone eq $sel;
657 $cb->append_text($zone);
661 # Append UTC here, so it is always the last item and never the default for any country.
662 $cb->append_text('UTC');
664 $cb->set_active($selected_index || 0);
667 $box->pack_start($cb, 0, 0, 0);
670 sub create_password_view
{
674 my $password = Proxmox
::Install
::Config
::get_password
();
676 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
677 $gtk_state->{inbox
}->pack_start($vbox2, 1, 0, 0);
678 my $vbox = Gtk3
::Box-
>new('vertical', 0);
679 $vbox2->pack_start($vbox, 0, 0, 10);
681 my $hbox1 = Gtk3
::Box-
>new('horizontal', 0);
682 my $label = Gtk3
::Label-
>new("Password");
683 $label->set_size_request(150, -1);
684 $label->set_xalign(1.0);
685 $hbox1->pack_start($label, 0, 0, 10);
686 my $pwe1 = Gtk3
::Entry-
>new();
687 $pwe1->set_visibility(0);
688 $pwe1->set_text($password) if $password;
689 $pwe1->set_size_request(200, -1);
690 $hbox1->pack_start($pwe1, 0, 0, 0);
692 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
693 $label = Gtk3
::Label-
>new("Confirm");
694 $label->set_size_request(150, -1);
695 $label->set_xalign(1.0);
696 $hbox2->pack_start($label, 0, 0, 10);
697 my $pwe2 = Gtk3
::Entry-
>new();
698 $pwe2->set_visibility(0);
699 $pwe2->set_text($password) if $password;
700 $pwe2->set_size_request(200, -1);
701 $hbox2->pack_start($pwe2, 0, 0, 0);
703 my $hbox3 = Gtk3
::Box-
>new('horizontal', 0);
704 $label = Gtk3
::Label-
>new("Email");
705 $label->set_size_request(150, -1);
706 $label->set_xalign(1.0);
707 $hbox3->pack_start($label, 0, 0, 10);
708 my $eme = Gtk3
::Entry-
>new();
709 $eme->set_size_request(200, -1);
710 $eme->set_text(Proxmox
::Install
::Config
::get_mailto
());
711 $hbox3->pack_start($eme, 0, 0, 0);
714 $vbox->pack_start($hbox1, 0, 0, 5);
715 $vbox->pack_start($hbox2, 0, 0, 5);
716 $vbox->pack_start($hbox3, 0, 0, 15);
718 $gtk_state->{inbox
}->show_all;
720 Proxmox
::UI
::display_html
('passwd.htm');
722 set_next
(undef, sub {
724 my $t1 = $pwe1->get_text;
725 my $t2 = $pwe2->get_text;
727 if (length ($t1) < 5) {
728 Proxmox
::UI
::message
("Password is too short.");
734 Proxmox
::UI
::message
("Password does not match.");
739 my $t3 = $eme->get_text;
740 if ($t3 !~ m/^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/) {
741 Proxmox
::UI
::message
("Email does not look like a valid address (user\@domain.tld)");
746 if ($t3 eq 'mail@example.invalid') {
747 Proxmox
::UI
::message
("Please enter a valid Email address");
752 Proxmox
::Install
::Config
::set_password
($t1);
753 Proxmox
::Install
::Config
::set_mailto
($t3);
756 create_ipconf_view
();
764 sub create_country_view
{
768 my $locales = $iso_env->{locales
};
770 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
771 $gtk_state->{inbox
}->pack_start($vbox2, 1, 0, 0);
772 my $vbox = Gtk3
::Box-
>new('vertical', 0);
773 $vbox2->pack_start($vbox, 0, 0, 10);
775 my $w = Gtk3
::Entry-
>new();
776 $w->set_size_request(200, -1);
778 my $c = Gtk3
::EntryCompletion-
>new();
779 $c->set_text_column(0);
780 $c->set_minimum_key_length(0);
781 $c->set_popup_set_width(1);
782 $c->set_inline_completion(1);
784 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
785 my $label = Gtk3
::Label-
>new("Time zone");
786 $label->set_size_request(150, -1);
787 $label->set_xalign(1.0);
788 $hbox2->pack_start($label, 0, 0, 10);
789 update_zonelist
($hbox2);
791 my $hbox3 = Gtk3
::Box-
>new('horizontal', 0);
792 $label = Gtk3
::Label-
>new("Keyboard Layout");
793 $label->set_size_request(150, -1);
794 $label->set_xalign(1.0);
795 $hbox3->pack_start($label, 0, 0, 10);
797 my $kmapcb = Gtk3
::ComboBoxText-
>new();
798 $kmapcb->set_size_request (200, -1);
799 for my $layout (sort keys %{$locales->{kmaphash
}}) {
800 $kmapcb->append_text($layout);
803 update_layout
($kmapcb);
804 $hbox3->pack_start ($kmapcb, 0, 0, 0);
806 $kmapcb->signal_connect ('changed' => sub {
807 my $sel = $kmapcb->get_active_text();
808 $last_layout = $kmapcb->get_active();
809 if (my $kmap = $locales->{kmaphash
}->{$sel}) {
810 my $xkmap = $locales->{kmap
}->{$kmap}->{x11
};
811 my $xvar = $locales->{kmap
}->{$kmap}->{x11var
};
813 Proxmox
::Install
::Config
::set_keymap
($kmap);
815 return if (defined($installer_kmap) && $installer_kmap eq $kmap);
816 $installer_kmap = $kmap;
818 if (!is_test_mode
()) {
819 syscmd
("setxkbmap $xkmap $xvar");
826 $kbd_config =~ s/^\s+//gm;
828 Proxmox
::Sys
::Command
::run_in_background
(sub {
829 file_write_all
('/etc/default/keyboard', $kbd_config);
836 $w->signal_connect ('changed' => sub {
837 my ($entry, $event) = @_;
838 my $text = $entry->get_text;
840 if (my $cc = $locales->{countryhash
}->{lc($text)}) {
841 update_zonelist
($hbox2, $cc);
842 my $kmap = $locales->{country
}->{$cc}->{kmap
} || 'en-us';
843 update_layout
($kmapcb, $kmap);
847 $w->signal_connect (key_press_event
=> sub {
848 my ($entry, $event) = @_;
849 my $text = $entry->get_text;
851 my $val = $event->get_keyval;
853 if ($val == Gtk3
::Gdk
::KEY_Tab
) {
854 my $cc = $locales->{countryhash
}->{lc($text)};
861 $compl = $locales->{country
}->{$cc}->{name
};
863 for my $country (values $locales->{country
}->%*) {
864 if ($country->{name
} =~ m/^\Q$text\E.*$/i) {
866 $compl = $country->{name
};
873 $entry->set_text($compl);
882 my $buf = $w->get_buffer();
883 $buf->insert_text(-1, '', -1); # popup selection
891 my $country_store = Gtk3
::ListStore-
>new('Glib::String');
892 my $countries = $locales->{country
};
893 for my $cc (sort { $countries->{$a}->{name
} cmp $countries->{$b}->{name
} } keys %$countries) {
894 my $iter = $country_store->append();
895 $country_store->set($iter, 0, $countries->{$cc}->{name
});
897 $c->set_model($country_store);
899 $w->set_completion ($c);
901 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
903 $label = Gtk3
::Label-
>new("Country");
904 $label->set_xalign(1.0);
905 $label->set_size_request(150, -1);
906 $hbox->pack_start($label, 0, 0, 10);
907 $hbox->pack_start($w, 0, 0, 0);
909 $vbox->pack_start($hbox, 0, 0, 5);
910 $vbox->pack_start($hbox2, 0, 0, 5);
911 $vbox->pack_start($hbox3, 0, 0, 5);
913 my $country = Proxmox
::Install
::Config
::get_country
();
914 if ($country && (my $entry = $locales->{country
}->{$country})) {
915 $w->set_text($entry->{name
});
918 $gtk_state->{inbox
}->show_all;
920 Proxmox
::UI
::display_html
('country.htm');
921 set_next
(undef, sub {
923 my $text = $w->get_text;
925 if (my $cc = $locales->{countryhash
}->{lc($text)}) {
926 Proxmox
::Install
::Config
::set_country
($cc);
928 create_password_view
();
931 Proxmox
::UI
::message
("Please select a country first.");
942 my $hdoption_first_setup = 1;
944 my $create_basic_grid = sub {
945 my $grid = Gtk3
::Grid-
>new();
946 $grid->set_visible(1);
947 $grid->set_column_spacing(10);
948 $grid->set_row_spacing(10);
949 $grid->set_hexpand(1);
951 $grid->set_margin_start(10);
952 $grid->set_margin_end(20);
953 $grid->set_margin_top(5);
954 $grid->set_margin_bottom(5);
959 my $create_label_widget_grid = sub {
960 my ($labeled_widgets) = @_;
962 my $grid = &$create_basic_grid();
965 for (my $i = 0; $i < @$labeled_widgets; $i += 2) {
966 my $widget = @$labeled_widgets[$i+1];
967 my $label = Gtk3
::Label-
>new(@$labeled_widgets[$i]);
968 $label->set_visible(1);
969 $label->set_xalign(1.0);
970 $grid->attach($label, 0, $row, 1, 1);
971 $widget->set_visible(1);
972 $grid->attach($widget, 1, $row, 1, 1);
979 # only relevant for raid with its multipl diskX to diskY mappings.
980 my $get_selected_hdsize = sub {
982 return $hdsize if defined($hdsize);
984 # compute the smallest disk size of the actually selected disks
985 my $cached_disks = get_cached_disks
();
986 my $disk_count = scalar(@$cached_disks);
987 for (my $i = 0; $i < $disk_count; $i++) {
988 my $cur_hd = $gtk_state->{disk_selection
}->{$i} // next;
989 my $disksize = int(@$cur_hd[2] / (2 * 1024 * 1024.0)); # size in GB
990 $hdsize //= $disksize;
991 $hdsize = $disksize if $disksize < $hdsize;
994 if (my $cfg_hdsize = Proxmox
::Install
::Config
::get_hdsize
()) {
995 # had the dialog open previously and set an even lower size than the disk selection allows
996 $hdsize = $cfg_hdsize if $cfg_hdsize < $hdsize;
998 return $hdsize // 0; # fall back to zero, e.g., if none is selected hdsize cannot be any size
1001 my sub update_hdsize_adjustment
{
1002 my ($adjustment, $hdsize) = @_;
1004 $hdsize = $get_selected_hdsize->($hdsize);
1005 # expect that lower = 0 and step increments = 1 still are valid
1006 $adjustment->set_upper($hdsize + 1);
1007 $adjustment->set_value($hdsize);
1010 my sub create_hdsize_adjustment
{
1012 $hdsize = $get_selected_hdsize->($hdsize);
1013 my $cfg_hdsize = Proxmox
::Install
::Config
::get_hdsize
();
1014 # params are: initial value, lower, upper, step increment, page increment, page size
1015 return Gtk3
::Adjustment-
>new($cfg_hdsize || $hdsize, 0, $hdsize+1, 1, 1, 1);
1018 my sub get_hdsize_spin_button
{
1021 my $hdsize_entry_buffer = Gtk3
::EntryBuffer-
>new(undef, 1);
1022 my $hdsize_size_adj = create_hdsize_adjustment
($hdsize);
1024 my $spinbutton_hdsize = Gtk3
::SpinButton-
>new($hdsize_size_adj, 1, 1);
1025 $spinbutton_hdsize->set_buffer($hdsize_entry_buffer);
1026 $spinbutton_hdsize->set_adjustment($hdsize_size_adj);
1027 $spinbutton_hdsize->set_tooltip_text("only use specified size (GB) of the harddisk (rest left unpartitioned)");
1028 return $spinbutton_hdsize;
1031 my $create_raid_disk_grid = sub {
1032 my ($hdsize_buttons) = @_;
1034 my $cached_disks = get_cached_disks
();
1035 my $disk_count = scalar(@$cached_disks);
1036 my $disk_labeled_widgets = [];
1037 for (my $i = 0; $i < $disk_count; $i++) {
1038 my $disk_selector = Gtk3
::ComboBoxText-
>new();
1039 $disk_selector->append_text("-- do not use --");
1040 $disk_selector->set_active(0);
1041 $disk_selector->set_visible(1);
1043 for my $hd (@$cached_disks) {
1044 my ($disk, $devname, $size, $model, $logical_bsize) = @$hd;
1045 $disk_selector->append_text(get_device_desc
($devname, $size, $model));
1048 $disk_selector->{pve_disk_id
} = $i;
1049 $disk_selector->signal_connect(changed
=> sub {
1051 my $diskid = $w->{pve_disk_id
};
1052 my $a = $w->get_active - 1;
1053 $gtk_state->{disk_selection
}->{$diskid} = ($a >= 0) ?
$cached_disks->[$a] : undef;
1054 for my $btn (@$hdsize_buttons) {
1055 update_hdsize_adjustment
($btn->get_adjustment());
1059 if ($hdoption_first_setup) {
1060 $disk_selector->set_active ($i+1) if $cached_disks->[$i];
1063 if (my $cur_hd = $gtk_state->{disk_selection
}->{$i}) {
1064 foreach my $hd (@$cached_disks) {
1065 if (@$hd[1] eq @$cur_hd[1]) {
1066 $disk_selector->set_active($hdind+1);
1074 push @$disk_labeled_widgets, "Harddisk $i", $disk_selector;
1077 my $clear_all_button = Gtk3
::Button-
>new('_Deselect All');
1078 if ($disk_count > 3) {
1079 $clear_all_button->signal_connect('clicked', sub {
1081 for my $disk_selector (@$disk_labeled_widgets) {
1082 $disk_selector->set_active(0) if $is_widget;
1086 $clear_all_button->set_visible(1);
1089 my $scrolled_window = Gtk3
::ScrolledWindow-
>new();
1090 $scrolled_window->set_hexpand(1);
1091 $scrolled_window->set_propagate_natural_height(1) if $disk_count > 4;
1093 my $diskgrid = $create_label_widget_grid->($disk_labeled_widgets);
1095 $scrolled_window->add($diskgrid);
1096 $scrolled_window->set_policy('never', 'automatic');
1097 $scrolled_window->set_visible(1);
1098 $scrolled_window->set_min_content_height(190);
1100 my $vbox = Gtk3
::Box-
>new('vertical', 0);
1101 $vbox->pack_start($scrolled_window, 1, 1, 10);
1103 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
1104 $hbox->pack_end($clear_all_button, 0, 0, 20);
1105 $hbox->set_visible(1);
1106 $vbox->pack_end($hbox, 0, 0, 0);
1111 my $create_raid_advanced_grid = sub {
1112 my ($hdsize_btn) = @_;
1113 my $labeled_widgets = [];
1114 my $spinbutton_ashift = Gtk3
::SpinButton-
>new_with_range(9, 13, 1);
1115 $spinbutton_ashift->set_tooltip_text("zpool ashift property (pool sector size, default 2^12)");
1116 $spinbutton_ashift->signal_connect ("value-changed" => sub {
1118 Proxmox
::Install
::Config
::set_zfs_opt
('ashift', $w->get_value_as_int());
1120 my $ashift = Proxmox
::Install
::Config
::get_zfs_opt
('ashift') // 12;
1121 $spinbutton_ashift->set_value($ashift);
1122 push @$labeled_widgets, "ashift";
1123 push @$labeled_widgets, $spinbutton_ashift;
1125 my $combo_compress = Gtk3
::ComboBoxText-
>new();
1126 $combo_compress->set_tooltip_text("zfs compression algorithm for rpool dataset");
1127 my $comp_opts = ["on","off","lzjb","lz4", "zle", "gzip", "zstd"];
1128 foreach my $opt (@$comp_opts) {
1129 $combo_compress->append($opt, $opt);
1131 my $compress = Proxmox
::Install
::Config
::get_zfs_opt
('compress') // 'on';
1132 $combo_compress->set_active_id($compress);
1133 $combo_compress->signal_connect (changed
=> sub {
1135 Proxmox
::Install
::Config
::set_zfs_opt
('compress', $w->get_active_text());
1137 push @$labeled_widgets, "compress";
1138 push @$labeled_widgets, $combo_compress;
1140 my $combo_checksum = Gtk3
::ComboBoxText-
>new();
1141 $combo_checksum->set_tooltip_text("zfs checksum algorithm for rpool dataset");
1142 my $csum_opts = ["on", "off","fletcher2", "fletcher4", "sha256"];
1143 foreach my $opt (@$csum_opts) {
1144 $combo_checksum->append($opt, $opt);
1146 my $checksum = Proxmox
::Install
::Config
::get_zfs_opt
('checksum') // 'on';
1147 $combo_checksum->set_active_id($checksum);
1148 $combo_checksum->signal_connect (changed
=> sub {
1150 Proxmox
::Install
::Config
::set_zfs_opt
('checksum', $w->get_active_text());
1152 push @$labeled_widgets, "checksum";
1153 push @$labeled_widgets, $combo_checksum;
1155 my $spinbutton_copies = Gtk3
::SpinButton-
>new_with_range(1,3,1);
1156 $spinbutton_copies->set_tooltip_text("zfs copies property for rpool dataset (in addition to RAID redundancy!)");
1157 $spinbutton_copies->signal_connect ("value-changed" => sub {
1159 Proxmox
::Install
::Config
::set_zfs_opt
('copies', $w->get_value_as_int());
1161 my $copies = Proxmox
::Install
::Config
::get_zfs_opt
('copies') // 1;
1162 $spinbutton_copies->set_value($copies);
1163 push @$labeled_widgets, "copies", $spinbutton_copies;
1165 push @$labeled_widgets, "hdsize", $hdsize_btn;
1166 return $create_label_widget_grid->($labeled_widgets);;
1169 my $create_btrfs_raid_advanced_grid = sub {
1170 my ($hdsize_btn) = @_;
1171 my $labeled_widgets = [];
1172 push @$labeled_widgets, "hdsize", $hdsize_btn;
1173 return $create_label_widget_grid->($labeled_widgets);;
1176 sub create_hdoption_view
{
1177 my $dialog = Gtk3
::Dialog-
>new();
1179 $dialog->set_title("Harddisk options");
1181 $dialog->add_button("_OK", 1);
1183 my $contarea = $dialog->get_content_area();
1185 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
1186 $contarea->pack_start($hbox2, 1, 1, 5);
1188 my $grid = Gtk3
::Grid-
>new();
1189 $grid->set_column_spacing(10);
1190 $grid->set_row_spacing(10);
1192 $hbox2->pack_start($grid, 1, 0, 5);
1197 my $label0 = Gtk3
::Label-
>new("Filesystem");
1198 $label0->set_xalign(1.0);
1199 $grid->attach($label0, 0, $row, 1, 1);
1201 my $fstypecb = Gtk3
::ComboBoxText-
>new();
1212 push @$fstype, 'btrfs (RAID0)', 'btrfs (RAID1)', 'btrfs (RAID10)'
1213 if $iso_env->{cfg
}->{enable_btrfs
};
1215 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1217 foreach my $tmp (@$fstype) {
1218 $fstypecb->append_text($tmp);
1219 $fstypecb->set_active ($tcount) if $filesys eq $tmp;
1223 $grid->attach($fstypecb, 1, $row, 1, 1);
1229 my $sep = Gtk3
::Separator-
>new('horizontal');
1230 $sep->set_visible(1);
1231 $grid->attach($sep, 0, $row, 2, 1);
1234 my $hw_raid_note = Gtk3
::Label-
>new(""); # text will be set below, before making it visible
1235 $hw_raid_note->set_line_wrap(1);
1236 $hw_raid_note->set_max_width_chars(30);
1237 $hw_raid_note->set_visible(0);
1238 $grid->attach($hw_raid_note, 0, $row++, 2, 1);
1240 my $hdsize_labeled_widgets = [];
1242 my $target_hd = Proxmox
::Install
::Config
::get_target_hd
();
1243 my $hdsize = 0; # size compute
1244 if ( -b
$target_hd) {
1245 $hdsize = int(Proxmox
::Sys
::Block
::hd_size
($target_hd) / (1024 * 1024.0)); # size in GB
1246 } elsif ($target_hd) {
1247 $hdsize = int((-s
$target_hd) / (1024 * 1024 * 1024.0));
1250 my $spinbutton_hdsize_nonraid = get_hdsize_spin_button
($hdsize);
1251 push @$hdsize_labeled_widgets, "hdsize", $spinbutton_hdsize_nonraid;
1252 my $spinbutton_hdsize = $spinbutton_hdsize_nonraid;
1254 my $entry_swapsize = Gtk3
::Entry-
>new();
1255 $entry_swapsize->set_tooltip_text("maximum SWAP size (GB)");
1256 $entry_swapsize->signal_connect (key_press_event
=> \
&check_float
);
1257 my $swapsize = Proxmox
::Install
::Config
::get_swapsize
();
1258 $entry_swapsize->set_text($swapsize) if defined($swapsize);
1259 push @$hdsize_labeled_widgets, "swapsize", $entry_swapsize;
1261 my $entry_maxroot = Gtk3
::Entry-
>new();
1262 if ($iso_env->{product
} eq 'pve') {
1263 $entry_maxroot->set_tooltip_text("maximum size (GB) for LVM root volume");
1264 $entry_maxroot->signal_connect (key_press_event
=> \
&check_float
);
1265 if (my $maxroot = Proxmox
::Install
::Config
::get_maxroot
()) {
1266 $entry_maxroot->set_text($maxroot);
1268 push @$hdsize_labeled_widgets, "maxroot", $entry_maxroot;
1271 my $entry_minfree = Gtk3
::Entry-
>new();
1272 $entry_minfree->set_tooltip_text("minimum free LVM space (GB, required for LVM snapshots)");
1273 $entry_minfree->signal_connect (key_press_event
=> \
&check_float
);
1274 if (defined(my $minfree = Proxmox
::Install
::Config
::get_minfree
())) {
1275 $entry_minfree->set_text($minfree);
1277 push @$hdsize_labeled_widgets, "minfree", $entry_minfree;
1280 if ($iso_env->{product
} eq 'pve') {
1281 $entry_maxvz = Gtk3
::Entry-
>new();
1282 $entry_maxvz->set_tooltip_text("maximum size (GB) for LVM data volume");
1283 $entry_maxvz->signal_connect (key_press_event
=> \
&check_float
);
1284 if (defined(my $maxvz = Proxmox
::Install
::Config
::get_maxvz
())) {
1285 $entry_maxvz->set_text($maxvz);
1287 push @$hdsize_labeled_widgets, "maxvz", $entry_maxvz;
1290 my $spinbutton_hdsize_zfs = get_hdsize_spin_button
($hdsize);
1291 my $spinbutton_hdsize_btrfs = get_hdsize_spin_button
($hdsize);
1292 my $hdsize_buttons = [ $spinbutton_hdsize_zfs, $spinbutton_hdsize_btrfs ];
1293 my $options_stack = Gtk3
::Stack-
>new();
1294 $options_stack->set_visible(1);
1295 $options_stack->set_hexpand(1);
1296 $options_stack->set_vexpand(1);
1297 $options_stack->add_titled(&$create_raid_disk_grid($hdsize_buttons), "raiddisk", "Disk Setup");
1298 $options_stack->add_titled(&$create_label_widget_grid($hdsize_labeled_widgets), "hdsize", "Size Options");
1299 $options_stack->add_titled(&$create_raid_advanced_grid($spinbutton_hdsize_zfs), "raidzfsadvanced", "Advanced Options");
1300 $options_stack->add_titled(&$create_btrfs_raid_advanced_grid($spinbutton_hdsize_btrfs), "raidbtrfsadvanced", "Advanced Options");
1301 $options_stack->set_visible_child_name("raiddisk");
1302 my $options_stack_switcher = Gtk3
::StackSwitcher-
>new();
1303 $options_stack_switcher->set_halign('center');
1304 $options_stack_switcher->set_stack($options_stack);
1305 $grid->attach($options_stack_switcher, 0, $row, 2, 1);
1307 $grid->attach($options_stack, 0, $row, 2, 1);
1310 $hdoption_first_setup = 0;
1312 my $switch_view = sub {
1313 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1314 my $raid = $filesys =~ m/zfs|btrfs/;
1315 my $is_zfs = $filesys =~ m/zfs/;
1317 $target_hd_combo->set_visible(!$raid);
1318 $options_stack->get_child_by_name("hdsize")->set_visible(!$raid);
1319 $options_stack->get_child_by_name("raiddisk")->set_visible($raid);
1322 my $msg = "<b>Note</b>: " . ($is_zfs
1323 ?
"ZFS is not compatible with hardware RAID controllers, for details see the documentation."
1324 : "BTRFS integration in $iso_env->{cfg}->{fullname} is a technology preview!"
1326 $hw_raid_note->set_markup($msg);
1328 $hw_raid_note->set_visible($raid);
1329 $options_stack_switcher->set_visible($raid);
1330 $options_stack->get_child_by_name("raidzfsadvanced")->set_visible($is_zfs);
1331 $options_stack->get_child_by_name("raidbtrfsadvanced")->set_visible(!$is_zfs);
1333 $target_hd_label->set_text("Target: $filesys ");
1334 $options_stack->set_visible_child_name("raiddisk");
1336 $target_hd_label->set_text("Target Harddisk: ");
1340 $spinbutton_hdsize = $is_zfs ?
$spinbutton_hdsize_zfs : $spinbutton_hdsize_btrfs;
1342 $spinbutton_hdsize = $spinbutton_hdsize_nonraid;
1345 my (undef, $pref_width) = $dialog->get_preferred_width();
1346 my (undef, $pref_height) = $dialog->get_preferred_height();
1347 $pref_height = 750 if $pref_height > 750;
1348 $dialog->resize($pref_width, $pref_height);
1353 $fstypecb->signal_connect (changed
=> sub {
1354 my $new_filesys = $fstypecb->get_active_text();
1355 Proxmox
::Install
::Config
::set_filesys
($new_filesys);
1359 my $sep2 = Gtk3
::Separator-
>new('horizontal');
1360 $sep2->set_visible(1);
1361 $contarea->pack_end($sep2, 1, 1, 10);
1367 my $get_float = sub {
1370 my $text = $entry->get_text();
1371 return undef if !defined($text);
1376 return undef if $text !~ m/^\d+(\.\d+)?$/;
1383 if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
1384 Proxmox
::Install
::Config
::set_hdsize
($tmp);
1386 Proxmox
::Install
::Config
::set_hdsize
(undef);
1389 if (defined($tmp = &$get_float($entry_swapsize))) {
1390 Proxmox
::Install
::Config
::set_swapsize
($tmp);
1392 Proxmox
::Install
::Config
::set_swapsize
(undef);
1395 if (defined($tmp = &$get_float($entry_maxroot))) {
1396 Proxmox
::Install
::Config
::set_maxroot
($tmp);
1398 Proxmox
::Install
::Config
::set_maxroot
(undef);
1401 if (defined($tmp = &$get_float($entry_minfree))) {
1402 Proxmox
::Install
::Config
::set_minfree
($tmp);
1404 Proxmox
::Install
::Config
::set_minfree
(undef);
1407 if ($entry_maxvz && defined($tmp = &$get_float($entry_maxvz))) {
1408 Proxmox
::Install
::Config
::set_maxvz
($tmp);
1410 Proxmox
::Install
::Config
::set_maxvz
(undef);
1416 sub apply_raid_disk_selection
{
1417 Proxmox
::Install
::Config
::set_key
('disk_selection', {}); # reset
1418 for my $order (sort keys $gtk_state->{disk_selection
}->%*) {
1419 my $disk = $gtk_state->{disk_selection
}->{$order} // next;
1420 Proxmox
::Install
::Config
::set_disk_selection
($order, $disk->[0]);
1424 my $last_hd_selected = 0;
1425 sub create_hdsel_view
{
1427 $gtk_state->{prev_btn
}->set_sensitive(1); # enable previous button at this point
1431 my $vbox = Gtk3
::Box-
>new('vertical', 0);
1432 $gtk_state->{inbox
}->pack_start($vbox, 1, 0, 0);
1433 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
1434 $vbox->pack_start($hbox, 0, 0, 10);
1436 my $cached_disks = get_cached_disks
();
1437 my ($disk, $devname, $size, $model, $logical_bsize) = $cached_disks->[0]->@*;
1438 if (!defined(Proxmox
::Install
::Config
::get_target_hd
())) {
1439 Proxmox
::Install
::Config
::set_target_hd
($devname);
1442 $target_hd_label = Gtk3
::Label-
>new("Target Harddisk: ");
1443 $hbox->pack_start($target_hd_label, 0, 0, 0);
1445 $target_hd_combo = Gtk3
::ComboBoxText-
>new();
1447 foreach my $hd ($cached_disks->@*) {
1448 ($disk, $devname, $size, $model, $logical_bsize) = @$hd;
1449 $target_hd_combo->append_text(get_device_desc
($devname, $size, $model));
1452 my $raid = Proxmox
::Install
::Config
::get_filesys
() =~ m/zfs|btrfs/;
1454 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1455 $target_hd_label->set_text("Target: $filesys ");
1456 $target_hd_combo->set_visible(0);
1457 $target_hd_combo->set_no_show_all(1);
1459 $target_hd_combo->set_active($last_hd_selected);
1460 $target_hd_combo->signal_connect(changed
=> sub {
1461 $a = shift-
>get_active;
1462 my ($disk, $devname) = @{@$cached_disks[$a]};
1463 $last_hd_selected = $a;
1464 Proxmox
::Install
::Config
::set_target_hd
($devname);
1467 $hbox->pack_start($target_hd_combo, 0, 0, 10);
1469 my $options = Gtk3
::Button-
>new('_Options');
1470 $options->signal_connect (clicked
=> \
&create_hdoption_view
);
1471 $hbox->pack_start ($options, 0, 0, 0);
1474 $gtk_state->{inbox
}->show_all;
1476 Proxmox
::UI
::display_html
('page1.htm');
1478 set_next
(undef, sub {
1479 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1480 if ($filesys =~ m/zfs/) {
1481 apply_raid_disk_selection
();
1482 my ($devlist) = eval { Proxmox
::Install
::get_zfs_raid_setup
() };
1484 Proxmox
::UI
::message
("Warning: $err\nPlease fix ZFS setup first.");
1487 $target_hds = [ map { $_->[1] } @$devlist ];
1488 } elsif ($filesys =~ m/btrfs/) {
1489 apply_raid_disk_selection
();
1490 my ($devlist) = eval { Proxmox
::Install
::get_btrfs_raid_setup
() };
1492 Proxmox
::UI
::message
("Warning: $err\nPlease fix BTRFS setup first.");
1495 $target_hds = [ map { $_->[1] } @$devlist ];
1497 my $target_hd = Proxmox
::Install
::Config
::get_target_hd
();
1499 my $target_block_size = Proxmox
::Sys
::Block
::logical_blocksize
($target_hd);
1500 Proxmox
::Install
::legacy_bios_4k_check
($target_block_size);
1503 Proxmox
::UI
::message
("Warning: $err\n");
1506 $target_hds = [ $target_hd ];
1510 create_country_view
();
1514 sub create_extract_view
{
1517 Proxmox
::Install
::display_info
();
1519 $gtk_state->{next_btn
}->set_sensitive(0);
1520 $gtk_state->{prev_btn
}->set_sensitive(0);
1521 $gtk_state->{prev_btn
}->hide();
1523 my $vbox = Gtk3
::Box-
>new('vertical', 0);
1524 $gtk_state->{inbox
}->pack_start ($vbox, 1, 0, 0);
1525 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
1526 $vbox->pack_start ($hbox, 0, 0, 10);
1528 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
1529 $hbox->pack_start ($vbox2, 0, 0, 0);
1531 $vbox2->pack_start($gtk_state->{progress_status
}, 1, 1, 0);
1533 $gtk_state->{progress_bar
}->set_show_text(1);
1534 $gtk_state->{progress_bar
}->set_size_request (600, -1);
1536 $vbox2->pack_start($gtk_state->{progress_bar
}, 0, 0, 0);
1538 $gtk_state->{inbox
}->show_all();
1540 eval { Proxmox
::Install
::extract_data
() };
1543 $gtk_state->{next_btn
}->set_sensitive(1);
1545 set_next
("_Reboot", sub { app_quit
(0); } );
1547 my $autoreboot = Proxmox
::Install
::Config
::get_autoreboot
();
1548 my $autoreboot_seconds = 5;
1549 my $success_transform = sub {
1550 my ($raw_html, $iso_env) = @_;
1552 my $ip_addr = Proxmox
::Install
::Config
::get_ip_addr
();
1553 my $ip_version = Proxmox
::Install
::Config
::get_ip_version
();
1555 my $addr = $ip_version == 6 ?
"[${ip_addr}]" : "$ip_addr";
1556 $raw_html =~ s/__IPADDR__/$addr/g;
1557 $raw_html =~ s/__PORT__/$iso_env->{cfg}->{port}/g;
1559 my $autoreboot_msg = $autoreboot ?
"Automatic reboot scheduled in $autoreboot_seconds seconds." : '';
1560 $raw_html =~ s/__AUTOREBOOT_MSG__/$autoreboot_msg/;
1565 # It does not make sense to Abort the install at this point, whether it
1566 # succeded or failed makes no difference.
1567 $gtk_state->{abort_btn
}->set_sensitive(0);
1570 Proxmox
::UI
::display_html
("fail.htm");
1571 # suppress "empty" error as we got some case where the user choose to abort on a prompt,
1572 # there it doesn't make sense to show them an error again, they "caused" it after all.
1573 Proxmox
::UI
::error
($err) if $err ne "\n";
1576 Proxmox
::UI
::display_html
("success.htm", $success_transform);
1579 Glib
::Timeout-
>add(1000, sub {
1580 if ($autoreboot_seconds > 0) {
1581 $autoreboot_seconds--;
1582 Proxmox
::UI
::display_html
("success.htm", $success_transform);
1583 return 1; # re-schedule, undef isn't enough anymore since Bookworm
1592 sub create_intro_view
{
1594 $gtk_state->{prev_btn
}->set_sensitive(0);
1598 my $run_env = Proxmox
::Install
::RunEnv
::get
();
1599 if (int($run_env->{total_memory
}) < 1024) {
1600 Proxmox
::UI
::error
("Less than 1 GiB of usable memory detected, installation will probably fail.\n\n".
1601 "See 'System Requirements' in the $iso_env->{cfg}->{fullname} documentation.");
1604 if ($iso_env->{product
} eq 'pve' && !$run_env->{hvm_supported
}) {
1606 "No support for hardware-accelerated KVM virtualization detected.\n\n"
1607 ."Check BIOS settings for Intel VT / AMD-V / SVM."
1611 Proxmox
::UI
::display_html
('license.htm', sub {
1612 my ($raw_html, $iso_env) = @_;
1614 my $proxmox_cddir = $iso_env->{locations
}->{iso
};
1615 my $license = eval { decode
('utf8', file_read_all
("${proxmox_cddir}/EULA")) };
1617 die $err if !is_test_mode
();
1618 $license = "TESTMODE: Ignore non existent EULA...\n";
1620 my $title = "END USER LICENSE AGREEMENT (EULA)";
1621 $raw_html =~ s/__LICENSE__/$license/;
1622 $raw_html =~ s/__LICENSE_TITLE__/$title/;
1628 set_next
("I a_gree", \
&create_hdsel_view
);
1631 log_info
("initializing GTK and creating main window...");
1634 create_main_window
();
1636 my $initial_error = 0;
1639 my $cached_disks = get_cached_disks
();
1640 if (!defined($cached_disks) || (scalar (@$cached_disks) <= 0)) {
1641 print STDERR
"no harddisks found\n";
1643 Proxmox
::UI
::display_html
("nohds.htm");
1644 set_next
("Reboot", sub { app_quit
(0); } );
1646 foreach my $hd (@$cached_disks) {
1647 my ($disk, $devname) = @$hd;
1648 next if $devname =~ m
|^/dev/md\d
+$|;
1649 print STDERR
"found Disk$disk N:$devname\n";
1654 my $run_env = Proxmox
::Install
::RunEnv
::get
();
1655 if (!$initial_error && (scalar keys $run_env->{ipconf
}->{ifaces
}->%* == 0)) {
1656 print STDERR
"no network interfaces found\n";
1658 Proxmox
::UI
::display_html
("nonics.htm");
1659 set_next
("Reboot", sub { app_quit
(0); } );
1662 create_intro_view
() if !$initial_error;