]>
git.proxmox.com Git - pve-installer.git/blob - proxinstall
3 $ENV{DEBIAN_FRONTEND
} = 'noninteractive';
16 use String
::ShellQuote
;
22 my $kapi = `uname -r`;
27 if (!$ENV{G_SLICE
} || $ENV{G_SLICE
} ne "always-malloc") {
28 die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
31 if (!GetOptions
('testmode=s' => \
$opt_testmode)) {
36 my $zfspoolname = $opt_testmode ?
"test_rpool" : 'rpool';
38 my $storage_cfg_zfs = <<__EOD__;
41 content iso,vztmpl,backup
44 pool $zfspoolname/data
46 content images,rootdir
49 my $storage_cfg_lvmthin = <<__EOD__;
52 content iso,vztmpl,backup
57 content rootdir,images
61 sub file_read_firstline
{
64 my $fh = IO
::File-
>new ($filename, "r");
72 my $logfd = IO
::File-
>new (">/tmp/install.log");
74 my $proxmox_dir = $opt_testmode ? Cwd
::cwd
() : "/var/lib/pve-installer";
76 my $grub_plattform = "pc"; # pc, efi-amd64 or efi-ia32
78 $grub_plattform = "efi-amd64" if -d
"/sys/firmware/efi";
80 my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])";
81 my $IPV4RE = "(?:(?:$IPV4OCTET\\.){3}$IPV4OCTET)";
82 my $IPV6H16 = "(?:[0-9a-fA-F]{1,4})";
83 my $IPV6LS32 = "(?:(?:$IPV4RE|$IPV6H16:$IPV6H16))";
86 "(?:(?:" . "(?:$IPV6H16:){6})$IPV6LS32)|" .
87 "(?:(?:" . "::(?:$IPV6H16:){5})$IPV6LS32)|" .
88 "(?:(?:(?:" . "$IPV6H16)?::(?:$IPV6H16:){4})$IPV6LS32)|" .
89 "(?:(?:(?:(?:$IPV6H16:){0,1}$IPV6H16)?::(?:$IPV6H16:){3})$IPV6LS32)|" .
90 "(?:(?:(?:(?:$IPV6H16:){0,2}$IPV6H16)?::(?:$IPV6H16:){2})$IPV6LS32)|" .
91 "(?:(?:(?:(?:$IPV6H16:){0,3}$IPV6H16)?::(?:$IPV6H16:){1})$IPV6LS32)|" .
92 "(?:(?:(?:(?:$IPV6H16:){0,4}$IPV6H16)?::" . ")$IPV6LS32)|" .
93 "(?:(?:(?:(?:$IPV6H16:){0,5}$IPV6H16)?::" . ")$IPV6H16)|" .
94 "(?:(?:(?:(?:$IPV6H16:){0,6}$IPV6H16)?::" . ")))";
96 my $IPRE = "(?:$IPV4RE|$IPV6RE)";
99 my $ipv4_mask_hash = {
116 '255.255.128.0' => 17,
117 '255.255.192.0' => 18,
118 '255.255.224.0' => 19,
119 '255.255.240.0' => 20,
120 '255.255.248.0' => 21,
121 '255.255.252.0' => 22,
122 '255.255.254.0' => 23,
123 '255.255.255.0' => 24,
124 '255.255.255.128' => 25,
125 '255.255.255.192' => 26,
126 '255.255.255.224' => 27,
127 '255.255.255.240' => 28,
128 '255.255.255.248' => 29,
129 '255.255.255.252' => 30
132 my ($window, $cmdbox, $inbox, $htmlview);
133 my ($next, $next_fctn, $target_hd);
134 my ($progress, $progress_status);
135 my ($ipversion, $ipaddress, $ipconf_entry_addr);
136 my ($netmask, $ipconf_entry_mask);
137 my ($gateway, $ipconf_entry_gw);
138 my ($dnsserver, $ipconf_entry_dns);
139 my $hostname = 'proxmox';
140 my $domain = 'domain.tld';
141 my $cmdline = file_read_firstline
("/proc/cmdline");
144 my $timezone = 'Europe/Vienna';
147 my $keymap = 'en-us';
150 # parse command line args
152 my $config_options = {};
154 if ($cmdline =~ m/\s(ext3|ext4|xfs|zfs)(\s.*)?$/) {
155 $config_options->{filesys
} = $1;
157 $config_options->{filesys
} = 'ext4';
160 if ($cmdline =~ m/hdsize=(\d+(\.\d+)?)[\s\n]/i) {
161 $config_options->{hdsize
} = $1;
164 if ($cmdline =~ m/swapsize=(\d+(\.\d+)?)[\s\n]/i) {
165 $config_options->{swapsize
} = $1;
168 if ($cmdline =~ m/maxroot=(\d+(\.\d+)?)[\s\n]/i) {
169 $config_options->{maxroot
} = $1;
172 if ($cmdline =~ m/minfree=(\d+(\.\d+)?)[\s\n]/i) {
173 $config_options->{minfree
} = $1;
176 if ($cmdline =~ m/maxvz=(\d+(\.\d+)?)[\s\n]/i) {
177 $config_options->{maxvz
} = $1;
180 my $postfix_main_cf = <<_EOD;
181 # See /usr/share/postfix/main.cf.dist for a commented, more complete version
185 smtpd_banner = \$myhostname ESMTP \$mail_name (Debian/GNU)
188 # appending .domain is the MUA's job.
189 append_dot_mydomain = no
191 # Uncomment the next line to generate "delayed mail" warnings
192 #delay_warning_time = 4h
194 alias_maps = hash:/etc/aliases
195 alias_database = hash:/etc/aliases
196 mydestination = \$myhostname, localhost.\$mydomain, localhost
198 mynetworks = 127.0.0.0/8
199 inet_interfaces = loopback-only
200 recipient_delimiter = +
207 return String
::ShellQuote
::shell_quote
($str);
213 die "no arguments" if !$cmd;
215 return $cmd if !ref($cmd);
218 foreach my $arg (@$cmd) { push @qa, shellquote
($arg); }
220 return join (' ', @qa);
226 return run_command
($cmd, undef, undef, 1);
230 my ($cmd, $func, $input, $noout) = @_;
236 # see 'man bash' for option pipefail
237 $cmd = [ '/bin/bash', '-c', "set -o pipefail && $cmd" ];
242 $cmdstr = cmd2string
($cmd);
246 if ($input && ($cmdstr !~ m/chpasswd/)) {
247 $cmdtxt = "# $cmdstr <<EOD\n$input";
249 $cmdtxt .= "\nEOD\n";
251 $cmdtxt = "# $cmdstr\n";
259 print $logfd $cmdtxt;
261 my $reader = IO
::File-
>new();
262 my $writer = IO
::File-
>new();
263 my $error = IO
::File-
>new();
269 $pid = open3
($writer, $reader, $error, @$cmd) || die $!;
275 if ($orig_pid != $$) {
282 print $writer $input if defined $input;
285 my $select = new IO
::Select
;
286 $select->add ($reader);
287 $select->add ($error);
289 my ($ostream, $logout) = ('', '', '');
291 while ($select->count) {
292 my @handles = $select->can_read (0.2);
294 Gtk3
::main_iteration
() while Gtk3
::events_pending
();
296 next if !scalar (@handles); # timeout
298 foreach my $h (@handles) {
300 my $count = sysread ($h, $buf, 4096);
301 if (!defined ($count)) {
305 die "command '$cmd' failed: $err";
307 $select->remove ($h) if !$count;
309 $ostream .= $buf if !($noout || $func);
311 while ($logout =~ s/^([^\010\r\n]*)(\r|\n|(\010)+|\r\n)//s) {
313 &$func($line) if $func;
316 } elsif ($h eq $error) {
317 $ostream .= $buf if !($noout || $func);
325 &$func($logout) if $func;
327 my $rv = waitpid ($pid, 0);
329 return $? if $noout; # behave like standard system();
334 die "command '$cmdstr' failed with exit code $ec";
342 print "trying to detect country...\n";
343 my $cpid = open2
(\
*TMP
, undef, "traceroute -N 1 -q 1 -n 8.8.8.8");
344 return undef if !$cpid;
348 my $previous_alarm = alarm (10);
350 local $SIG{ALRM
} = sub { die "timed out!\n" };
352 while (defined ($line = <TMP
>)) {
353 print $logfd "DC TRACEROUTE: $line";
354 if ($line =~ m/\s*\d+\s+(\d+\.\d+\.\d+\.\d+)\s/) {
355 my $geoip = `geoiplookup $1`;
356 print $logfd "DC GEOIP: $geoip";
357 if ($geoip =~ m/GeoIP Country Edition:\s*([A-Z]+),/) {
359 print $logfd "DC FOUND: $country\n";
368 alarm ($previous_alarm);
373 print "unable to detect country - $err\n";
375 print "detected country: " . uc($country) . "\n";
377 print "unable to detect country\n";
385 open (MEMINFO, "/proc/meminfo");
387 my $res = 512; # default to 512 if something goes wrong
388 while (my $line = <MEMINFO>) {
389 if ($line =~ m/^MemTotal:\s+(\d+)\s*kB/i) {
390 $res = int ($1 / 1024);
399 my $total_memory = get_memtotal();
402 my ($src, $dest) = @_;
404 my ($dev1,$ino1) = stat ($src);
405 my ($dev2,$ino2) = stat ($dest);
407 return 0 if !($dev1 && $dev2 && $ino1 && $ino2);
409 return $ino1 == $ino2 && $dev1 == $dev2;
412 sub find_stable_path {
413 my ($stabledir, $bdev) = @_;
415 foreach my $path (<$stabledir/*>) {
416 if (link_points_to ($path, $bdev)) {
417 return wantarray ? ($path, basename($path)) : $path;
422 sub find_dev_by_uuid {
425 my ($full_path, $name) = find_stable_path ("/dev/disk/by-uuid", $bdev);
435 push @$res, [-1, $opt_testmode, int((-s $opt_testmode)/512), "TESTDISK"];
440 foreach my $bd (</sys/block/*>) {
441 next if $bd =~ m|^/sys/block/ram\d+$|;
442 next if $bd =~ m|^/sys/block/loop\d+$|;
443 next if $bd =~ m|^/sys/block/md\d+$|;
444 next if $bd =~ m|^/sys/block/dm-.*$|;
445 next if $bd =~ m|^/sys/block/fd\d+$|;
446 next if $bd =~ m|^/sys/block/sr\d+$|;
448 my $dev = file_read_firstline("$bd/dev");
453 my $info = `udevadm info
--path
$bd --query all
`;
456 next if $info !~ m/^E: DEVTYPE=disk$/m;
458 next if $info =~ m/^E: ID_CDROM/m;
460 my ($name) = $info =~ m/^N: (\S+)$/m;
463 my $real_name = "/dev/$name";
465 my $size = file_read_firstline("$bd/size");
467 $size = undef if !($size && $size =~ m/^\d+$/);
469 my $model = file_read_firstline("$bd/device/model") || '';
472 if (length ($model) > 30) {
473 $model = substr ($model, 0, 30);
475 push @$res, [$count++, $real_name, $size, $model] if $size;
477 print STDERR "ERROR: unable to map device $dev ($bd)\n";
485 my $countryfn = $opt_testmode ? "/usr/share/pve-manager/country.dat" :
486 "/proxmox/country.dat";
487 open (TMP, "<$countryfn") || die "unable to open '$countryfn' - $!\n";
490 my $countryhash = {};
493 while (defined ($line = <TMP>)) {
494 if ($line =~ m|^map:([^\s:]+):([^:]+):([^:]+):([^:]+):([^:]+):([^:]*):$|) {
502 $kmaphash->{$2} = $1;
503 } elsif ($line =~ m|^([a-z]{2}):([^:]+):([^:]*):([^:]*):$|) {
509 $countryhash->{lc($2)} = $1;
511 warn "unable to parse 'country.dat' line: $line";
518 my $zonefn = "/usr/share/zoneinfo/zone.tab";
519 open (TMP, "<$zonefn") || die "unable to open '$zonefn' - $!\n";
520 while (defined ($line = <TMP>)) {
521 next if $line =~ m/^\#/;
522 next if $line =~ m/^\s*$/;
523 if ($line =~ m|^([A-Z][A-Z])\s+\S+\s+(([^/]+)/\S+)\s|) {
525 $cczones->{$cc}->{$2} = 1;
526 $country->{$cc}->{zone} = $2 if !defined ($country->{$cc}->{zone});
537 countryhash => $countryhash,
539 kmaphash => $kmaphash,
543 # search for Harddisks
544 my $hds = hd_list ();
549 foreach my $hd (@$hds) {
550 my ($disk, $devname, $size, $model) = @$hd;
551 return int($size/2) if $devname eq $dev;
554 die "no such device '$dev'";
557 sub get_partition_dev {
558 my ($dev, $partnum) = @_;
560 if ($dev =~ m|^/dev/[hxsev]d[a-z]$|) {
561 return "${dev}$partnum";
562 } elsif ($dev =~ m|^/dev/[^/]+/c\d+d\d+$|) {
563 return "${dev}p$partnum";
564 } elsif ($dev =~ m|^/dev/[^/]+/d\d+$|) {
565 return "${dev}p$partnum";
566 } elsif ($dev =~ m|^/dev/[^/]+/hd[a-z]$|) {
567 return "${dev}$partnum";
568 } elsif ($dev =~ m|^/dev/nvme\d+n\d+$|) {
569 return "${dev}p$partnum";
571 die "unable to get device for partition $partnum on device $dev\n";
576 sub file_get_contents {
577 my ($filename, $max) = @_;
579 my $fh = IO::File->new($filename, "r") ||
580 die "can't open '$filename' - $!\n";
582 local $/; # slurp mode
592 my ($text, $filename) = @_;
594 my $fd = IO::File->new (">$filename") ||
595 die "unable to open file '$filename' - $!";
600 sub update_progress {
601 my ($frac, $start, $end, $text) = @_;
603 my $part = $end - $start;
604 my $res = $start + $frac*$part;
606 $progress->set_fraction ($res);
607 $progress->set_text (sprintf ("%d%%", int ($res*100)));
608 $progress_status->set_text ($text) if defined ($text);
610 Gtk3::main_iteration() while Gtk3::events_pending();
615 mkfs => 'mkfs.ext3 -F',
617 mkfs_data_opt => '-m 0',
618 root_mountopt => 'errors=remount-ro',
621 mkfs => 'mkfs.ext4 -F',
623 mkfs_data_opt => '-m 0',
624 root_mountopt => 'errors=remount-ro',
627 mkfs => 'mkfs.xfs -f',
634 sub create_filesystem {
635 my ($dev, $name, $type, $start, $end, $fs, $fe) = @_;
637 my $range = $end - $start;
638 my $rs = $start + $range*$fs;
639 my $re = $start + $range*$fe;
642 my $fsdata = $fssetup->{$type} || die "internal error - unknown file system '$type'";
643 my $opts = $name eq 'root' ? $fsdata->{mkfs_root_opt} : $fsdata->{mkfs_data_opt};
645 update_progress (0, $rs, $re, "creating $name filesystem");
647 run_command ("$fsdata->{mkfs} $opts $dev", sub {
650 if ($line =~ m/Writing inode tables:\s+(\d+)\/(\d+)/) {
652 } elsif ($max && $line =~ m/(\d+)\/$max/) {
653 update_progress (($1/$max)*0.9, $rs, $re);
654 } elsif ($line =~ m/Creating journal.*done/) {
655 update_progress (0.95, $rs, $re);
656 } elsif ($line =~ m/Writing superblocks and filesystem.*done/) {
657 update_progress (1, $rs, $re);
663 my ($targetdir, $dcdata) = @_;
665 my $cfgfile = "/tmp/debconf.txt";
666 write_config ($dcdata, "$targetdir/$cfgfile");
667 syscmd ("chroot $targetdir debconf-set-selections $cfgfile");
668 unlink "$targetdir/$cfgfile";
672 my ($targetdir, $cmd, $new_cmd) = @_;
674 syscmd ("chroot $targetdir dpkg-divert --package proxmox " .
675 "--add --rename $cmd") == 0 ||
676 die "unable to exec dpkg-divert\n";
678 syscmd ("ln -sf ${new_cmd} $targetdir/$cmd") == 0 ||
679 die "unable to link diversion to ${new_cmd}\n";
682 sub diversion_remove {
683 my ($targetdir, $cmd) = @_;
685 syscmd ("mv $targetdir/${cmd}.distrib $targetdir/${cmd};") == 0 ||
686 die "unable to remove $cmd diversion\n";
688 syscmd ("chroot $targetdir dpkg-divert --remove $cmd") == 0 ||
689 die "unable to remove $cmd diversion\n";
692 sub zfs_create_rpool {
695 syscmd ("zpool create -f -o ashift=12 -o cachefile=none $zfspoolname $vdev") == 0 ||
696 die "unable to create zfs root pool\n";
698 syscmd ("zfs create $zfspoolname/ROOT") == 0 ||
699 die "unable to create zfs $zfspoolname/ROOT volume\n";
701 syscmd ("zfs create $zfspoolname/data") == 0 ||
702 die "unable to create zfs $zfspoolname/data volume\n";
704 syscmd ("zfs create $zfspoolname/ROOT/pve-1") == 0 ||
705 die "unable to create zfs $zfspoolname/ROOT/pve-1 volume\n";
707 # disable atime during insatll
708 syscmd ("zfs set atime=off $zfspoolname") == 0 ||
709 die "unable to set zfs properties\n";
710 syscmd ("zfs set compression=lz4 $zfspoolname") == 0 ||
711 die "unable to set zfs properties\n";
714 sub zfs_create_swap {
717 syscmd ("zfs create -V ${swapsize}K -b 4K $zfspoolname/swap") == 0 ||
718 die "unable to create zfs swap device\n";
720 syscmd ("zfs set com.sun:auto-snapshot=false $zfspoolname/swap") == 0 ||
721 die "unable to set zfs properties\n";
723 # reduces memory pressure
724 syscmd ("zfs set sync=always $zfspoolname/swap") == 0 ||
725 die "unable to set zfs properties\n";
727 return "/dev/zvol/$zfspoolname/swap";
730 sub partition_bootable_disk {
731 my ($target_dev, $maxhdsize, $use_zfs) = @_;
733 die "too dangerous" if $opt_testmode;
735 syscmd("sgdisk -Z ${target_dev}");
736 my $hdsize = hd_size($target_dev); # size in blocks (1024 bytes)
738 my $restricted_hdsize_mb = 0; # 0 ==> end of partition
739 if ($maxhdsize && ($maxhdsize < $hdsize)) {
740 $hdsize = $maxhdsize;
741 $restricted_hdsize_mb = int($hdsize/1024) . 'M';
744 my $hdgb = int($hdsize/(1024*1024));
745 die "hardisk '$target_dev' too small (${hdsize}GB)" if $hdgb < 8;
747 # 1 - GRUB boot partition: 1M
749 # 3 - OS/Data partition
751 my $grubbootdev = get_partition_dev($target_dev, 1);
752 my $efibootdev = get_partition_dev($target_dev, 2);
753 my $osdev = get_partition_dev ($target_dev, 3);
755 my $pcmd = ['sgdisk', '-a1'];
758 push @$pcmd, "-n$pnum:34:2047", "-t$pnum:EF02";
761 # Note: from 128M to end
762 push @$pcmd, "-n$pnum:128M:${restricted_hdsize_mb}", "-t$pnum:8E00";
765 # Note: from sector 2048 to 128M (0 mean till next partition)
766 push @$pcmd, "-n$pnum:2048:0", "-t$pnum:EF00";
768 push @$pcmd, $target_dev;
770 my $os_size = $hdsize - 128*1024;
772 syscmd($pcmd) == 0 ||
773 die "unable to partition harddisk '${target_dev}'\n";
775 return ($os_size, $osdev, $efibootdev);
778 # ZFS has this use_whole_disk concept, so we try to partition the same
779 # way as zfs does by default. There is room at start of disk to insert
780 # a grub boot partition. But adding a EFI ESP is not possible.
782 # Note: zfs people think this is just a waste of space an not
783 # required. Instead, you should put the ESP on another disk (log,
786 sub partition_bootable_zfs_disk {
787 my ($target_dev) = @_;
789 die "too dangerous" if $opt_testmode;
791 syscmd("sgdisk -Z ${target_dev}");
792 my $hdsize = hd_size($target_dev); # size in blocks (1024 bytes)
794 my $hdgb = int($hdsize/(1024*1024));
795 die "hardisk '$target_dev' too small (${hdsize}GB)" if $hdgb < 8;
797 # 1 - GRUB boot partition: 1M
798 # 2 - OS/Data partition
799 # 9 - ZFS reserved partition
801 my $grubbootdev = get_partition_dev($target_dev, 1);
802 my $osdev = get_partition_dev ($target_dev, 2);
804 my $pcmd = ['sgdisk', '-a1'];
807 push @$pcmd, "-n$pnum:34:2047", "-t$pnum:EF02";
810 push @$pcmd, "-n$pnum:-8M:0", "-t$pnum:BF07";
813 push @$pcmd, "-n$pnum:2048:0", "-t$pnum:BF01", '-c', "$pnum:zfs";
815 push @$pcmd, $target_dev;
817 my $os_size = $hdsize - 1024 - 1024*8;
819 syscmd($pcmd) == 0 ||
820 die "unable to partition harddisk '${target_dev}'\n";
822 return ($os_size, $osdev);
825 sub create_lvm_volumes {
826 my ($lvmdev, $os_size, $swap_size) = @_;
828 my $rootdev = '/dev/pve/root';
829 my $datadev = '/dev/pve/data';
830 my $swapfile = '/dev/pve/swap';
832 # we use --metadatasize 250k, which reseults in "pe_start = 512"
833 # so pe_start is aligned on a 128k boundary (advantage for SSDs)
834 syscmd ("/sbin/pvcreate --metadatasize 250k -y -ff $lvmdev") == 0 ||
835 die "unable to initialize physical volume $lvmdev";
836 syscmd ("/sbin/vgcreate pve $lvmdev") == 0 ||
837 die "unable to create volume group";
839 my $hdgb = int($os_size/(1024*1024));
840 my $space = (($hdgb > 128) ? 16 : ($hdgb/8))*1024*1024;
843 if ($config_options->{maxroot}) {
844 $maxroot = $config_options->{maxroot};
849 my $rootsize = (($hdgb > ($maxroot*4)) ? $maxroot : $hdgb/4)*1024*1024;
851 my $rest = $os_size - $swap_size - $rootsize; # in KB
854 if ($config_options->{minfree}) {
855 $minfree = (($config_options->{minfree}*1024*1024) >= $rest ) ? $space :
856 $config_options->{minfree}*1024*1024 ;
861 $rest = $rest - $minfree;
863 if ($config_options->{maxvz}) {
864 $rest = (($config_options->{maxvz}*1024*1024) <= $rest) ?
865 $config_options->{maxvz}*1024*1024 : $rest;
868 syscmd ("/sbin/lvcreate -L${swap_size}K -nswap pve") == 0 ||
869 die "unable to create swap volume";
871 syscmd ("/sbin/lvcreate -L${rootsize}K -nroot pve") == 0 ||
872 die "unable to create root volume";
874 syscmd ("/sbin/lvcreate -L${rest}K -ndata pve") == 0 ||
875 die "unable to create data volume";
877 syscmd ("/sbin/lvconvert --yes --type thin-pool pve/data") == 0 ||
878 die "unable to create data thin-pool";
880 syscmd ("/sbin/vgchange -a y pve") == 0 ||
881 die "unable to activate volume group";
883 return ($rootdev, $datadev, $swapfile);
886 sub compute_swapsize {
889 my $hdgb = int($hdsize/(1024*1024));
892 if ($config_options->{swapsize}) {
893 $swapsize = $config_options->{swapsize}*1024*1024;
895 my $ss = int ($total_memory / 1024);
897 $ss = ($hdgb/8) if $ss > ($hdgb/8);
899 $swapsize = $ss*1024*1024;
904 my ($tgzfile, $targetdir) = @_;
906 die "target '$targetdir' does not exist\n" if ! -d $targetdir;
908 my $bootdevinfo = [];
916 my $filesys = $config_options->{filesys};
918 if ($filesys =~ m/zfs/) {
919 $target_hd = undef; # do not use this config
921 $targetdir = "/$zfspoolname/ROOT/pve-1";
928 for ($i = 5; $i > 0; $i--) {
929 syscmd("modprobe zfs");
930 last if -c "/dev/zfs";
934 die "unable to load zfs kernel module\n" if !$i;
942 update_progress (0, 0, $maxper, "create partitions");
946 $rootdev = abs_path($target_hd);
947 syscmd ("umount $rootdev");
951 die "unsupported zfs mode (for testing environment)\n"
952 if $filesys ne 'zfs (RAID0)';
954 syscmd ("zpool destroy $zfspoolname") if $opt_testmode;
956 zfs_create_rpool($rootdev);
961 my ($devlist, $bootdevlist, $vdev) = get_zfs_raid_setup();
964 foreach my $hd (@$bootdevlist) {
965 my $devname = @$hd[1];
967 partition_bootable_zfs_disk($devname);
968 die "unable to mirror disks with different sizes!\n"
969 if $disksize && ($size != $disksize);
970 push @$bootdevinfo, { devname => $devname, osdev => $osdev};
974 sleep(1); # give kernel time to reread part table
976 # trigger udev to create /dev/disk/by-uuid
977 syscmd ("udevadm trigger --subsystem-match block");
978 syscmd ("udevadm settle --timeout 10");
980 foreach my $di (@$bootdevinfo) {
981 my $devname = $di->{devname};
982 $di->{by_id} = find_stable_path ("/dev/disk/by-id", $devname);
984 # Note: using /dev/disk/by-id/ does not work for unknown reason, we get
985 # cannot create 'rpool': no such pool or dataset
986 #my $osdev = find_stable_path ("/dev/disk/by-id", $di->{osdev}) || $di->{osdev};
988 my $osdev = $di->{osdev};
989 $vdev =~ s/ $devname/ $osdev/;
992 zfs_create_rpool($vdev);
994 my $swap_size = compute_swapsize($disksize);
995 $swapfile = zfs_create_swap($swap_size);
999 die "target '$target_hd' is not a valid block device\n" if ! -b $target_hd;
1002 if ($config_options->{hdsize}) {
1003 # max hdsize passed on cmdline (GB)
1004 $maxhdsize = $config_options->{hdsize}*1024*1024;
1007 my ($os_size, $osdev, $efidev);
1008 ($os_size, $osdev, $efidev) =
1009 partition_bootable_disk($target_hd, $maxhdsize);
1011 sleep(1); # give kernel time to reread part table
1013 # trigger udev to create /dev/disk/by-uuid
1014 syscmd ("udevadm trigger --subsystem-match block");
1015 syscmd ("udevadm settle --timeout 10");
1017 my $by_id = find_stable_path ("/dev/disk/by-id", $target_hd);
1018 push @$bootdevinfo, { esp => $efidev, devname => $target_hd,
1019 osdev => $osdev, by_id => $by_id };
1021 my $swap_size = compute_swapsize($os_size);
1022 ($rootdev, $datadev, $swapfile) =
1023 create_lvm_volumes($osdev, $os_size, $swap_size);
1025 # trigger udev to create /dev/disk/by-uuid
1026 syscmd ("udevadm trigger --subsystem-match block");
1027 syscmd ("udevadm settle --timeout 10");
1031 # to be fast during installation
1032 syscmd ("zfs set sync=disabled $zfspoolname") == 0 ||
1033 die "unable to set zfs properties\n";
1036 update_progress (0.03, 0, $maxper, "create swap space");
1038 syscmd ("mkswap -f $swapfile") == 0 ||
1039 die "unable to create swap space\n";
1042 update_progress (0.05, 0, $maxper, "creating filesystems");
1044 foreach my $di (@$bootdevinfo) {
1045 next if !$di->{esp};
1046 syscmd ("mkfs.vfat -F32 $di->{esp}") == 0 ||
1047 die "unable to initialize EFI ESP on device $di->{esp}\n";
1052 if ( -b $target_hd) {
1054 create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1);
1058 create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1);
1062 update_progress (1, 0.05, $maxper, "mounting target $rootdev");
1065 syscmd ("mount -n $rootdev -o noatime,barrier=0 $targetdir") == 0 ||
1066 die "unable to mount $rootdev\n";
1069 mkdir "$targetdir/boot";
1070 mkdir "$targetdir/boot/efi";
1072 mkdir "$targetdir/var";
1073 mkdir "$targetdir/var/lib";
1074 mkdir "$targetdir/var/lib/vz";
1076 display_html ("extract2-rulesystem.htm");
1077 update_progress (1, 0.05, $maxper, "extracting base system");
1079 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat ($tgzfile);
1080 $ino || die "unable to open file '$tgzfile' - $!\n";
1083 if ($opt_testmode) {
1084 $files = file_read_firstline("/pve/$release/install/pve-base.cnt");
1086 $files = file_read_firstline("/proxmox/pve-base.cnt");
1092 run_command ("tar xvf $tgzfile -C $targetdir", sub {
1095 my $nper = int (($count *100)/$files);
1096 if ($nper != $per) {
1098 my $frac = $per > 100 ? 100 : $per/100;
1099 update_progress ($frac, $maxper, 0.5);
1103 syscmd ("mount -n -t tmpfs tmpfs $targetdir/tmp") == 0 ||
1104 die "unable to mount tmpfs on $targetdir/tmp\n";
1105 syscmd ("mount -n -t proc proc $targetdir/proc") == 0 ||
1106 die "unable to mount proc on $targetdir/proc\n";
1107 syscmd ("mount -n -t sysfs sysfs $targetdir/sys") == 0 ||
1108 die "unable to mount sysfs on $targetdir/sys\n";
1110 display_html ("extract3-spam.htm");
1111 update_progress (1, $maxper, 0.5, "configuring base system");
1116 "127.0.0.1 localhost.localdomain localhost\n" .
1117 "$ipaddress $hostname.$domain $hostname pvelocalhost\n\n" .
1118 "# The following lines are desirable for IPv6 capable hosts\n\n" .
1119 "::1 ip6-localhost ip6-loopback\n" .
1120 "fe00::0 ip6-localnet\n" .
1121 "ff00::0 ip6-mcastprefix\n" .
1122 "ff02::1 ip6-allnodes\n" .
1123 "ff02::2 ip6-allrouters\n" .
1124 "ff02::3 ip6-allhosts\n";
1126 write_config ($hosts, "$targetdir/etc/hosts");
1128 write_config ("$hostname\n", "$targetdir/etc/hostname");
1130 syscmd ("/bin/hostname $hostname") if !$opt_testmode;
1132 # configure interfaces
1134 my $ifaces = "auto lo\niface lo inet loopback\n\n";
1136 my $ntype = $ipversion == 4 ? 'inet' : 'inet6';
1139 "auto vmbr0\niface vmbr0 $ntype static\n" .
1140 "\taddress $ipaddress\n" .
1141 "\tnetmask $netmask\n" .
1142 "\tgateway $gateway\n" .
1143 "\tbridge_ports eth0\n" .
1144 "\tbridge_stp off\n" .
1147 write_config ($ifaces, "$targetdir/etc/network/interfaces");
1151 my $resolfconf = "search $domain\nnameserver $dnsserver\n";
1152 write_config ($resolfconf, "$targetdir/etc/resolv.conf");
1156 my $fstab = "# <file system> <mount point> <type> <options> <dump> <pass>\n";
1159 my $root_mountopt = $fssetup->{$filesys}->{root_mountopt} || 'defaults';
1160 $fstab .= "$rootdev / $filesys ${root_mountopt} 0 1\n";
1164 # Note: this is required by current grub, but really dangerous, because
1165 # vfat does not have journaling, so it triggers manual fsck after each crash
1166 # so we only mount /boot/efi if really required (efi systems).
1167 if ($grub_plattform =~ m/^efi-/) {
1168 if (scalar(@$bootdevinfo)) {
1169 my $di = @$bootdevinfo[0]; # simply use first disk
1171 my $efi_boot_uuid = $di->{esp};
1172 if (my $uuid = find_dev_by_uuid ($di->{esp})) {
1173 $efi_boot_uuid = "UUID=$uuid";
1176 $fstab .= "${efi_boot_uuid} /boot/efi vfat defaults 0 1\n";
1182 $fstab .= "$swapfile none swap sw 0 0\n" if $swapfile;
1184 $fstab .= "proc /proc proc defaults 0 0\n";
1186 write_config ($fstab, "$targetdir/etc/fstab");
1187 write_config ("", "$targetdir/etc/mtab");
1189 syscmd ("cp ${proxmox_dir}/policy-disable-rc.d " .
1190 "$targetdir/usr/sbin/policy-rc.d") == 0 ||
1191 die "unable to copy policy-rc.d\n";
1192 syscmd ("cp ${proxmox_dir}/fake-start-stop-daemon " .
1193 "$targetdir/sbin/") == 0 ||
1194 die "unable to copy start-stop-daemon\n";
1196 diversion_add ($targetdir, "/sbin/start-stop-daemon", "/sbin/fake-start-stop-daemon");
1197 diversion_add ($targetdir, "/usr/sbin/update-grub", "/bin/true");
1198 diversion_add ($targetdir, "/usr/sbin/update-initramfs", "/bin/true");
1200 syscmd ("touch $targetdir/proxmox_install_mode");
1202 my $grub_install_devices_txt = '';
1203 foreach my $di (@$bootdevinfo) {
1204 $grub_install_devices_txt .= ', ' if $grub_install_devices_txt;
1205 $grub_install_devices_txt .= $di->{by_id} || $di->{devname};
1208 # Note: debian-installer/locale is used by console-setup
1210 debconfig_set ($targetdir, <<_EOD);
1211 locales locales/default_environment_locale select en_US.UTF-8
1212 locales locales/locales_to_be_generated select en_US.UTF-8 UTF-8
1213 samba-common samba-common/dhcp boolean false
1214 samba-common samba-common/workgroup string WORKGROUP
1215 postfix postfix/main_mailer_type select Local only
1216 keyboard-configuration keyboard-configuration/xkb-keymap select $keymap
1217 d-i debian-installer/locale select en_US.UTF-8
1218 grub-pc grub-pc/install_devices select $grub_install_devices_txt
1221 my $pkgdir = $opt_testmode ?
"packages" : "/proxmox/packages";
1223 while (<$pkgdir/*.deb
>) { $pkg_count++ };
1226 while (<$pkgdir/*.deb
>) {
1229 my ($deb) = $path =~ m/$pkgdir\/(.*\
.deb
)/;
1230 # if ($deb =~ m/^grub-efi-/ && $deb !~ m/^grub-${grub_plattform}/) {
1234 update_progress
($count/$pkg_count, 0.5, 0.75, "extracting $deb");
1235 print "extracting: $deb\n";
1236 syscmd
("cp $path $targetdir/tmp/$deb") == 0 ||
1237 die "installation of package $deb failed\n";
1238 syscmd
("chroot $targetdir dpkg --force-depends --no-triggers --unpack /tmp/$deb") == 0 ||
1239 die "installation of package $deb failed\n";
1240 update_progress
((++$count)/$pkg_count, 0.5, 0.75);
1243 display_html
("extract4-virus.htm");
1245 my $cmd = "chroot $targetdir dpkg --force-confold --configure -a";
1247 run_command
($cmd, sub {
1249 if ($line =~ m/Setting up\s+(\S+)/) {
1250 update_progress
((++$count)/$pkg_count, 0.75, 0.95,
1255 debconfig_set
($targetdir, <<_EOD);
1256 postfix postfix/main_mailer_type select No configuration
1259 unlink "$targetdir/etc/mailname";
1260 $postfix_main_cf =~ s/__FQDN__/${hostname}.${domain}/;
1261 write_config
($postfix_main_cf, "$targetdir/etc/postfix/main.cf");
1263 # make sure we have all postfix directories
1264 syscmd
("chroot $targetdir /usr/sbin/postfix check");
1265 # cleanup mail queue
1266 syscmd
("chroot $targetdir /usr/sbin/postsuper -d ALL");
1268 # enable NTP (timedatectl set-ntp true does not work without DBUS)
1269 syscmd
("chroot $targetdir /bin/systemctl enable systemd-timesyncd.service");
1271 unlink "$targetdir/proxmox_install_mode";
1274 unlink ("$targetdir/etc/localtime");
1275 symlink ("/usr/share/zoneinfo/$timezone", "$targetdir/etc/localtime");
1276 write_config
("$timezone\n", "$targetdir/etc/timezone");
1279 if (my $mirror = $cmap->{country
}->{$country}->{mirror
}) {
1280 my $fn = "$targetdir/etc/apt/sources.list";
1281 syscmd
("sed -i 's/ftp\\.debian\\.org/$mirror/' '$fn'");
1284 # create extended_states for apt (avoid cron job warning if that
1285 # file does not exist)
1286 write_config
('', "$targetdir/var/lib/apt/extended_states");
1288 # allow ssh root login
1289 syscmd
("sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' '$targetdir/etc/ssh/sshd_config'");
1291 # save installer settings
1292 my $ucc = uc ($country);
1293 debconfig_set
($targetdir, <<_EOD);
1294 pve-manager pve-manager/country string $ucc
1297 update_progress
(0.8, 0.95, 1, "make system bootable");
1300 syscmd
("sed -i -e 's/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"root=ZFS=$zfspoolname\\/ROOT\\/pve-1 boot=zfs\"/' $targetdir/etc/default/grub") == 0 ||
1301 die "unable to update /etc/default/grub\n";
1305 diversion_remove
($targetdir, "/usr/sbin/update-grub");
1306 diversion_remove
($targetdir, "/usr/sbin/update-initramfs");
1308 if (!$opt_testmode) {
1310 unlink ("$targetdir/etc/mtab");
1311 symlink ("/proc/mounts", "$targetdir/etc/mtab");
1312 syscmd
("mount -n --bind /dev $targetdir/dev");
1314 syscmd
("chroot $targetdir /usr/sbin/update-initramfs -c -k $kapi") == 0 ||
1315 die "unable to install initramfs\n";
1317 foreach my $di (@$bootdevinfo) {
1318 my $dev = $di->{devname
};
1319 syscmd
("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
1320 die "unable to install the i386-pc boot loader on '$dev'\n";
1323 syscmd
("mount -n $di->{esp} $targetdir/boot/efi") == 0 ||
1324 die "unable to mount $di->{esp}\n";
1325 syscmd
("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
1326 die "unable to install the EFI boot loader on '$dev'\n";
1327 # also install fallback boot file (OVMF does not boot without)
1328 mkdir("$targetdir/boot/efi/EFI/BOOT");
1329 syscmd
("cp $targetdir/boot/efi/EFI/proxmox/grubx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.EFI") == 0 ||
1330 die "unable to copy efi boot loader\n";
1332 syscmd
("umount $targetdir/boot/efi") == 0 ||
1333 die "unable to umount $targetdir/boot/efi\n";
1337 syscmd
("chroot $targetdir /usr/sbin/update-grub") == 0 ||
1338 die "unable to update boot loader config\n";
1340 syscmd
("umount $targetdir/dev");
1345 # hack: remove dead.letter from sshd installation
1346 syscmd
("rm -rf $targetdir/dead.letter");
1348 unlink "$targetdir/usr/sbin/policy-rc.d";
1350 diversion_remove
($targetdir, "/sbin/start-stop-daemon");
1353 my $octets = encode
("utf-8", $password);
1354 run_command
("chroot $targetdir /usr/sbin/chpasswd", undef,
1359 my $tmpdir = "$targetdir/tmp/pve";
1362 # write vnc keymap to datacenter.cfg
1363 my $vnckmap = $cmap->{kmap
}->{$keymap}->{kvm
} || 'en-us';
1364 write_config
("keyboard: $vnckmap\n",
1365 "$tmpdir/datacenter.cfg");
1368 write_config
("user:root\@pam:1:0:::${mailto}::\n",
1369 "$tmpdir/user.cfg");
1372 my $strorage_cfg_fn = "$tmpdir/storage.cfg";
1374 write_config
($storage_cfg_zfs, $strorage_cfg_fn);
1376 write_config
($storage_cfg_lvmthin, $strorage_cfg_fn);
1379 run_command
("chroot $targetdir /usr/bin/create_pmxcfs_db /tmp/pve /var/lib/pve-cluster/config.db");
1381 syscmd
("rm -rf $tmpdir");
1386 update_progress
(1, 0, 1, "");
1390 if ($opt_testmode) {
1391 syscmd
("chroot $targetdir /usr/bin/dpkg-query -W --showformat='\${package}\n'> pve-final.pkglist");
1394 syscmd
("umount $targetdir/var/lib/vz");
1395 syscmd
("umount $targetdir/tmp");
1396 syscmd
("umount $targetdir/proc");
1397 syscmd
("umount $targetdir/sys");
1400 syscmd
("zfs umount -a") == 0 ||
1401 die "unable to unmount zfs\n";
1403 syscmd
("umount -d $targetdir");
1406 if (!$err && $use_zfs) {
1407 syscmd
("zfs set sync=standard $zfspoolname") == 0 ||
1408 die "unable to set zfs properties\n";
1410 syscmd
("zfs set mountpoint=/ $zfspoolname/ROOT/pve-1") == 0 ||
1411 die "zfs set mountpoint failed\n";
1413 syscmd
("zpool set bootfs=$zfspoolname/ROOT/pve-1 $zfspoolname") == 0 ||
1414 die "zfs set bootfs failed\n";
1421 my ($filename) = @_;
1423 my $path = "${proxmox_dir}/html/$filename";
1424 my $url = "file://$path";
1426 my $data = file_get_contents
($path);
1428 if ($filename eq 'license.htm') {
1429 my $licensefn = -f
"/EULA" ?
"/EULA" :
1430 $opt_testmode ?
"./copyright" :
1431 "/usr/share/doc/pve-installer/copyright";
1432 my $license = decode
('utf8', file_get_contents
($licensefn));
1433 $license =~ m/^\s+(.+\n)/;
1434 my $title = $licensefn eq '/EULA' ?
"END USER LICENSE AGREEMENT (EULA)": $1;
1435 $data =~ s/__LICENSE__/$license/;
1436 $data =~ s/__LICENSE_TITLE__/$title/;
1439 $htmlview->load_html_string($data, $url);
1443 my ($text, $fctn) = @_;
1446 $text = "_Next" if !$text;
1447 $next->set_label ($text);
1449 $next->grab_focus ();
1453 my ($doc, $url, $stream) = @_;
1455 $stream->set_cancel_func (sub {}); # hack: avoid warning
1457 my $path = "${proxmox_dir}/html/$url";
1460 open (HTMLTMP
, $path) ||
1461 die "unable to open file '$path' - $! ";
1463 while (my $i = read (HTMLTMP
, $buf, 4096)) {
1464 $stream->write ($buf);
1465 Gtk3
::main_iteration
() while Gtk3
::events_pending
();
1470 #$stream->close(); # hack: dont close - avoid crash
1473 sub create_main_window
{
1475 $window = Gtk3
::Window-
>new ();
1476 $window->set_default_size (1024, 768);
1477 $window->set_has_resize_grip(0);
1478 $window->set_decorated (0) if !$opt_testmode;
1480 my $vbox = Gtk3
::VBox-
>new (0, 0);
1482 my $image = Gtk3
::Image-
>new_from_file ("${proxmox_dir}/proxlogo.xpm");
1483 $vbox->pack_start ($image, 0, 0, 0);
1485 my $hbox = Gtk3
::HBox-
>new (0, 0);
1486 $vbox->pack_start ($hbox, 1, 1, 0);
1488 # my $f1 = Gtk3::Frame->new ('test');
1489 # $f1->set_shadow_type ('none');
1490 # $hbox->pack_start ($f1, 1, 1, 0);
1492 my $sep1 = Gtk3
::HSeparator-
>new;
1493 $vbox->pack_start ($sep1, 0, 0, 0);
1495 $cmdbox = Gtk3
::HBox-
>new ();
1496 $vbox->pack_start ($cmdbox, 0, 0, 10);
1498 $next = Gtk3
::Button-
>new ('_Next');
1499 $next->signal_connect (clicked
=> sub { &$next_fctn (); });
1500 $cmdbox->pack_end ($next, 0, 0, 10);
1501 my $abort = Gtk3
::Button-
>new ('_Abort');
1502 $abort->set_can_focus (0);
1503 $cmdbox->pack_start ($abort, 0, 0, 10);
1504 $abort->signal_connect (clicked
=> sub { exit (-1); });
1506 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1507 $hbox->add ($vbox2);
1509 $htmlview = Gtk3
::WebKit
::WebView-
>new();
1510 my $scrolls = Gtk3
::ScrolledWindow-
>new();
1511 $scrolls->add($htmlview);
1513 my $hbox2 = Gtk3
::HBox-
>new (0, 0);
1514 $hbox2->pack_start ($scrolls, 1, 1, 0);
1516 $vbox2->pack_start ($hbox2, 1, 1, 0);
1518 my $vbox3 = Gtk3
::VBox-
>new (0, 0);
1519 $vbox2->pack_start ($vbox3, 0, 0, 0);
1521 my $sep2 = Gtk3
::HSeparator-
>new;
1522 $vbox3->pack_start ($sep2, 0, 0, 0);
1524 $inbox = Gtk3
::HBox-
>new (0, 0);
1525 $vbox3->pack_start ($inbox, 0, 0, 0);
1527 $window->add ($vbox);
1530 $window->realize ();
1534 $inbox->foreach(sub {
1536 $inbox->remove ($child);
1540 # fixme: newer GTK3 has special properties to handle numbers with Entry
1541 # only allow floating point numbers with Gtk3::Entry
1543 my ($entry, $event) = @_;
1546 my $val = $event->get_keyval;
1548 if ($val == ord '.' ||
1549 $val == Gtk3
::Gdk
::KEY_ISO_Left_Tab
||
1550 $val == Gtk3
::Gdk
::KEY_Shift_L
||
1551 $val == Gtk3
::Gdk
::KEY_Tab
||
1552 $val == Gtk3
::Gdk
::KEY_Left
||
1553 $val == Gtk3
::Gdk
::KEY_Right
||
1554 $val == Gtk3
::Gdk
::KEY_BackSpace
||
1555 $val == Gtk3
::Gdk
::KEY_Delete
||
1556 ($val >= ord '0' && $val <= ord '9') ||
1557 ($val >= Gtk3
::Gdk
::KEY_KP_0
&&
1558 $val <= Gtk3
::Gdk
::KEY_KP_9
)) {
1565 sub create_text_input
{
1566 my ($default, $text) = @_;
1568 my $hbox = Gtk3
::HBox-
>new (0, 0);
1570 my $label = Gtk3
::Label-
>new ($text);
1571 $label->set_size_request (150, -1);
1572 $label->set_alignment (1, 0.5);
1573 $hbox->pack_start ($label, 0, 0, 10);
1574 my $e1 = Gtk3
::Entry-
>new ();
1575 $e1->set_width_chars (30);
1576 $hbox->pack_start ($e1, 0, 0, 0);
1577 $e1->set_text ($default);
1579 return ($hbox, $e1);
1584 my $ifconfig = `ifconfig eth0`;
1586 my ($addr) = $ifconfig =~ m/inet addr:(\S*)/m;
1587 my ($mask) = $ifconfig =~ m/Mask:(\S*)/m;
1589 my $route = `route -n`;
1590 my ($gateway) = $route =~ m/^0\.0\.0\.0\s+(\d+\.\d+\.\d+\.\d+)\s+/m;
1592 my $resolvconf = `cat /etc/resolv.conf`;
1593 my ($dnsserver) = $resolvconf =~ m/^nameserver\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/m;
1594 my ($domain) = $resolvconf =~ m/^domain\s+(\S+)$/m;
1599 gateway
=> $gateway,
1600 dnsserver
=> $dnsserver,
1605 sub display_message
{
1608 my $dialog = Gtk3
::MessageDialog-
>new ($window, 'modal',
1609 'info', 'ok', $msg);
1617 my $dialog = Gtk3
::MessageDialog-
>new ($window, 'modal',
1618 'error', 'ok', $msg);
1623 sub create_ipconf_view
{
1626 display_html
("ipconf.htm");
1628 my $vbox = Gtk3
::VBox-
>new (0, 0);
1629 $inbox->pack_start ($vbox, 1, 0, 0);
1630 my $hbox = Gtk3
::HBox-
>new (0, 0);
1631 $vbox->pack_start ($hbox, 0, 0, 10);
1632 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1633 $hbox->add ($vbox2);
1635 my $addr = $ipconf->{addr
} || '192.168.100.2';
1636 my $mask = $ipconf->{mask
} || '255.255.255.0';
1638 my $hn = $ipconf->{domain
} ?
"pve.$ipconf->{domain}" : 'pve.domain.tld';
1640 my ($hostbox, $hostentry) =
1641 create_text_input
($hn, 'Hostname (FQDN):');
1642 $vbox2->pack_start ($hostbox, 0, 0, 2);
1645 ($ipbox, $ipconf_entry_addr) =
1646 create_text_input
($addr, 'IP Address:');
1647 $vbox2->pack_start ($ipbox, 0, 0, 2);
1650 ($maskbox, $ipconf_entry_mask) =
1651 create_text_input
($mask, 'Netmask:');
1652 $vbox2->pack_start ($maskbox, 0, 0, 2);
1654 $gateway = $ipconf->{gateway
} || '192.168.100.1';
1657 ($gwbox, $ipconf_entry_gw) =
1658 create_text_input
($gateway, 'Gateway:');
1660 $vbox2->pack_start ($gwbox, 0, 0, 2);
1662 $dnsserver = $ipconf->{dnsserver
} || $gateway;
1665 ($dnsbox, $ipconf_entry_dns) =
1666 create_text_input
($dnsserver, 'DNS Server:');
1668 $vbox2->pack_start ($dnsbox, 0, 0, 0);
1671 set_next
(undef, sub {
1675 my $text = $hostentry->get_text();
1680 my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
1682 if ($text && $text =~ m/^(${namere}\.)*${namere}$/ && $text !~ m/.domain.tld$/ &&
1683 $text =~ m/^([^\.]+)\.(\S+)$/) {
1687 display_message
("Hostname does not look like a fully qualified domain name.");
1688 $hostentry->grab_focus();
1694 $text = $ipconf_entry_addr->get_text();
1697 if ($text =~ m!^($IPV4RE)$!) {
1700 } elsif ($text =~ m!^($IPV6RE)$!) {
1704 display_message
("IP address is not valid.");
1705 $ipconf_entry_addr->grab_focus();
1709 $text = $ipconf_entry_mask->get_text();
1712 if (($ipversion == 6) && ($text =~ m/^(\d+)$/) && ($1 >= 8) && ($1 <= 126)) {
1714 } elsif (($ipversion == 4) && defined($ipv4_mask_hash->{$text})) {
1717 display_message
("Netmask is not valid.");
1718 $ipconf_entry_mask->grab_focus();
1722 $text = $ipconf_entry_gw->get_text();
1725 if (($ipversion == 4) && ($text =~ m!^($IPV4RE)$!)) {
1727 } elsif (($ipversion == 6) && ($text =~ m!^($IPV6RE)$!)) {
1730 display_message
("Gateway is not valid.");
1731 $ipconf_entry_gw->grab_focus();
1735 $text = $ipconf_entry_dns->get_text();
1738 if (($ipversion == 4) && ($text =~ m!^($IPV4RE)$!)) {
1740 } elsif (($ipversion == 6) && ($text =~ m!^($IPV6RE)$!)) {
1743 display_message
("DNS server is not valid.");
1744 $ipconf_entry_dns->grab_focus();
1748 #print "TEST $ipaddress $netmask $gateway $dnsserver\n";
1750 create_extract_view
();
1753 $hostentry->grab_focus();
1756 sub get_device_desc
{
1757 my ($devname, $size, $model) = @_;
1759 if ($size && ($size > 0)) {
1760 $size = int($size/2048); # size in MB
1762 my $text = "$devname (";
1763 if ($size >= 1024) {
1764 $size = int($size/1024); # size in GB
1765 $text .= "${size}GB";
1767 $text .= "${size}MB";
1770 $text .= ", $model" if $model;
1779 my ($cb, $kmap) = @_;
1784 my $kmaphash = $cmap->{kmaphash
};
1785 foreach my $layout (sort keys %$kmaphash) {
1786 $def = $i if $kmaphash->{$layout} eq 'en-us';
1787 $ind = $i if $kmap && $kmaphash->{$layout} eq $kmap;
1791 $cb->set_active ($ind || $def || 0);
1795 sub update_zonelist
{
1796 my ($box, $cc) = @_;
1798 my $cczones = $cmap->{cczones
};
1799 my $zones = $cmap->{zones
};
1803 $sel = $lastzonecb->get_active_text();
1804 $box->remove ($lastzonecb);
1806 $sel = $timezone; # used once to select default
1809 my $cb = $lastzonecb = Gtk3
::ComboBoxText-
>new();
1810 $cb->set_size_request (200, -1);
1812 $cb->signal_connect ('changed' => sub {
1813 $timezone = $cb->get_active_text();
1817 if ($cc && defined ($cczones->{$cc})) {
1818 @za = keys %{$cczones->{$cc}};
1824 foreach my $zone (sort @za) {
1825 $ind = $i if $sel && $zone eq $sel;
1826 $cb->append_text ($zone);
1830 $cb->set_active ($ind || 0);
1833 $box->pack_start ($cb, 0, 0, 0);
1836 sub create_password_view
{
1840 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1841 $inbox->pack_start ($vbox2, 1, 0, 0);
1842 my $vbox = Gtk3
::VBox-
>new (0, 0);
1843 $vbox2->pack_start ($vbox, 0, 0, 10);
1845 my $hbox1 = Gtk3
::HBox-
>new (0, 0);
1846 my $label = Gtk3
::Label-
>new ("Password");
1847 $label->set_size_request (150, -1);
1848 $label->set_alignment (1, 0.5);
1849 $hbox1->pack_start ($label, 0, 0, 10);
1850 my $pwe1 = Gtk3
::Entry-
>new ();
1851 $pwe1->set_visibility (0);
1852 $pwe1->set_size_request (200, -1);
1853 $hbox1->pack_start ($pwe1, 0, 0, 0);
1855 my $hbox2 = Gtk3
::HBox-
>new (0, 0);
1856 $label = Gtk3
::Label-
>new ("Confirm");
1857 $label->set_size_request (150, -1);
1858 $label->set_alignment (1, 0.5);
1859 $hbox2->pack_start ($label, 0, 0, 10);
1860 my $pwe2 = Gtk3
::Entry-
>new ();
1861 $pwe2->set_visibility (0);
1862 $pwe2->set_size_request (200, -1);
1863 $hbox2->pack_start ($pwe2, 0, 0, 0);
1865 my $hbox3 = Gtk3
::HBox-
>new (0, 0);
1866 $label = Gtk3
::Label-
>new ("E-Mail");
1867 $label->set_size_request (150, -1);
1868 $label->set_alignment (1, 0.5);
1869 $hbox3->pack_start ($label, 0, 0, 10);
1870 my $eme = Gtk3
::Entry-
>new ();
1871 $eme->set_size_request (200, -1);
1872 $hbox3->pack_start ($eme, 0, 0, 0);
1875 $vbox->pack_start ($hbox1, 0, 0, 5);
1876 $vbox->pack_start ($hbox2, 0, 0, 5);
1877 $vbox->pack_start ($hbox3, 0, 0, 15);
1881 display_html
("passwd.htm");
1883 set_next
(undef, sub {
1885 my $t1 = $pwe1->get_text;
1886 my $t2 = $pwe2->get_text;
1888 if (length ($t1) < 5) {
1889 display_message
("Password is too short.");
1890 $pwe1->grab_focus();
1895 display_message
("Password does not match.");
1896 $pwe1->grab_focus();
1900 my $t3 = $eme->get_text;
1901 if ($t3 !~ m/^\S+\@\S+\.\S+$/) {
1902 display_message
("E-Mail does not look like a vaild address" .
1903 " (user\@domain.tld)");
1912 create_ipconf_view
();
1915 $pwe1->grab_focus();
1919 sub create_country_view
{
1923 my $countryhash = $cmap->{countryhash
};
1924 my $ctr = $cmap->{country
};
1926 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1927 $inbox->pack_start ($vbox2, 1, 0, 0);
1928 my $vbox = Gtk3
::VBox-
>new (0, 0);
1929 $vbox2->pack_start ($vbox, 0, 0, 10);
1931 my $w = Gtk3
::Entry-
>new ();
1932 $w->set_size_request (200, -1);
1934 my $c = Gtk3
::EntryCompletion-
>new ();
1935 $c->set_text_column (0);
1936 $c->set_minimum_key_length(0);
1937 $c->set_popup_set_width (1);
1938 $c->set_inline_completion (1);
1940 my $hbox2 = Gtk3
::HBox-
>new (0, 0);
1941 my $label = Gtk3
::Label-
>new ("Time zone");
1942 $label->set_size_request (150, -1);
1943 $label->set_alignment (1, 0.5);
1944 $hbox2->pack_start ($label, 0, 0, 10);
1945 update_zonelist
($hbox2);
1947 my $hbox3 = Gtk3
::HBox-
>new (0, 0);
1948 $label = Gtk3
::Label-
>new ("Keyboard Layout");
1949 $label->set_size_request (150, -1);
1950 $label->set_alignment (1, 0.5);
1951 $hbox3->pack_start ($label, 0, 0, 10);
1953 my $kmapcb = Gtk3
::ComboBoxText-
>new();
1954 $kmapcb->set_size_request (200, -1);
1955 foreach my $layout (sort keys %{$cmap->{kmaphash
}}) {
1956 $kmapcb->append_text ($layout);
1959 update_layout
($kmapcb);
1960 $hbox3->pack_start ($kmapcb, 0, 0, 0);
1962 $kmapcb->signal_connect ('changed' => sub {
1963 my $sel = $kmapcb->get_active_text();
1964 if (my $kmap = $cmap->{kmaphash
}->{$sel}) {
1965 my $xkmap = $cmap->{kmap
}->{$kmap}->{x11
};
1966 my $xvar = $cmap->{kmap
}->{$kmap}->{x11var
};
1967 syscmd
("setxkbmap $xkmap $xvar") if !$opt_testmode;
1972 $w->signal_connect ('changed' => sub {
1973 my ($entry, $event) = @_;
1974 my $text = $entry->get_text;
1976 if (my $cc = $countryhash->{lc($text)}) {
1977 update_zonelist
($hbox2, $cc);
1978 my $kmap = $ctr->{$cc}->{kmap
} || 'en-us';
1979 update_layout
($kmapcb, $kmap);
1983 $w->signal_connect (key_press_event
=> sub {
1984 my ($entry, $event) = @_;
1985 my $text = $entry->get_text;
1987 my $val = $event->get_keyval;
1989 if ($val == Gtk3
::Gdk
::KEY_Tab
) {
1990 my $cc = $countryhash->{lc($text)};
1997 $compl = $ctr->{$cc}->{name
};
1999 foreach my $cc (keys %$ctr) {
2000 my $ct = $ctr->{$cc}->{name
};
2001 if ($ct =~ m/^\Q$text\E.*$/i) {
2010 $entry->set_text($compl);
2015 print chr(7); # beep ?
2020 my $buf = $w->get_buffer();
2021 $buf->insert_text(-1, '', -1); # popup selection
2029 my $ls = Gtk3
::ListStore-
>new('Glib::String');
2030 foreach my $cc (sort {$ctr->{$a}->{name
} cmp $ctr->{$b}->{name
} } keys %$ctr) {
2031 my $iter = $ls->append();
2032 $ls->set ($iter, 0, $ctr->{$cc}->{name
});
2034 $c->set_model ($ls);
2036 $w->set_completion ($c);
2038 my $hbox = Gtk3
::HBox-
>new (0, 0);
2040 $label = Gtk3
::Label-
>new ("Country");
2041 $label->set_alignment (1, 0.5);
2042 $label->set_size_request (150, -1);
2043 $hbox->pack_start ($label, 0, 0, 10);
2044 $hbox->pack_start ($w, 0, 0, 0);
2046 $vbox->pack_start ($hbox, 0, 0, 5);
2047 $vbox->pack_start ($hbox2, 0, 0, 5);
2048 $vbox->pack_start ($hbox3, 0, 0, 5);
2051 $w->set_text ($ctr->{$country}->{name
});
2056 display_html
("country.htm");
2057 set_next
(undef, sub {
2059 my $text = $w->get_text;
2061 if (my $cc = $countryhash->{lc($text)}) {
2063 create_password_view
();
2066 display_message
("Please select a country first.");
2074 my $target_hd_combo;
2075 my $target_hd_label;
2077 my $hdopion_first_setup = 1;
2079 sub create_hdoption_view
{
2081 my $dialog = Gtk3
::Dialog-
>new();
2083 $dialog->set_title("Harddisk options");
2085 $dialog->add_button("_OK", 1);
2087 my $contarea = $dialog->get_content_area();
2089 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
2090 $contarea->pack_start($hbox2, 1, 1, 10);
2092 my $grid = Gtk3
::Grid-
>new();
2093 $grid->set_column_spacing(10);
2094 $grid->set_row_spacing(10);
2096 $hbox2->pack_start($grid, 1, 0, 10);
2102 my $label0 = Gtk3
::Label-
>new ("Filesystem");
2103 $label0->set_alignment (1, 0.5);
2104 $grid->attach($label0, 0, $row, 1, 1);
2106 my $fstypecb = Gtk3
::ComboBoxText-
>new();
2108 my $fstype = ['ext3', 'ext4', 'xfs', 'zfs (RAID0)', 'zfs (RAID1)',
2109 'zfs (RAID10)', 'zfs (RAIDZ-1)',
2110 'zfs (RAIDZ-2)', 'zfs (RAIDZ-3)'];
2113 foreach my $tmp (@$fstype) {
2114 $fstypecb->append_text($tmp);
2115 $fstypecb->set_active ($tcount)
2116 if $config_options->{filesys
} eq $tmp;
2120 $grid->attach($fstypecb, 1, $row, 1, 1);
2128 for (my $i = 0; $i < 8; $i++) {
2129 $disk_label[$i] = Gtk3
::Label-
>new ("Hardisk $i");
2130 $disk_label[$i]->set_alignment (1, 0.5);
2131 $grid->attach($disk_label[$i], 0, $row, 1, 1);
2132 $disk_selector[$i] = Gtk3
::ComboBoxText-
>new();
2133 $disk_selector[$i]->append_text("-- do not use --");
2134 $disk_selector[$i]->set_active(0);
2135 foreach my $hd (@$hds) {
2136 my ($disk, $devname, $size, $model) = @$hd;
2137 $disk_selector[$i]->append_text(get_device_desc
($devname, $size, $model));
2138 $disk_selector[$i]->{pve_disk_id
} = $i;
2139 $disk_selector[$i]->signal_connect (changed
=> sub {
2141 my $diskid = $w->{pve_disk_id
};
2142 my $a = $w->get_active - 1;
2143 $config_options->{"disksel${diskid}"} = ($a >= 0) ?
$hds->[$a] : undef;
2147 if ($hdopion_first_setup) {
2148 $disk_selector[$i]->set_active ($i+1) if $hds->[$i];
2151 if (my $cur_hd = $config_options->{"disksel$i"}) {
2152 foreach my $hd (@$hds) {
2153 if (@$hd[1] eq @$cur_hd[1]) {
2154 $disk_selector[$i]->set_active($hdind+1);
2163 $grid->attach($disk_selector[$i], 1, $row, 1, 1);
2168 $hdopion_first_setup = 0;
2170 my $label_hdsize = Gtk3
::Label-
>new ("hdsize");
2171 $label_hdsize->set_alignment (1, 0.5);
2172 $grid->attach($label_hdsize, 0, $row, 1, 1);
2176 if ( -b
$target_hd) {
2177 $hdsize = int(hd_size
($target_hd) / (1024*1024.0)); # size in GB
2178 } elsif ($target_hd) {
2179 $hdsize = int((-s
$target_hd) / (1024*1024*1024.0));
2182 my $hdsize_size_adj = Gtk3
::Adjustment-
>new($config_options->{hdsize
} || $hdsize, 0, $hdsize+1, 1, 1, 1);
2183 my $spinbutton_hdsize = Gtk3
::SpinButton-
>new($hdsize_size_adj, 1, 1);
2184 $spinbutton_hdsize->set_tooltip_text("only use specified size (GB) of the harddisk (rest left unpartitioned)");
2185 $grid->attach($spinbutton_hdsize, 1, $row, 1, 1);
2188 my $label_swapsize = Gtk3
::Label-
>new ("swapsize");
2189 $label_swapsize->set_alignment (1, 0.5);
2190 $grid->attach($label_swapsize, 0, $row, 1, 1);
2192 my $entry_swapsize = Gtk3
::Entry-
>new();
2193 $entry_swapsize->set_tooltip_text("maximum SWAP size (GB)");
2194 $entry_swapsize->signal_connect (key_press_event
=> \
&check_float
);
2195 $entry_swapsize->set_text($config_options->{swapsize
}) if $config_options->{swapsize
};
2196 $grid->attach($entry_swapsize, 1, $row, 1, 1);
2199 my $label_maxroot = Gtk3
::Label-
>new ("maxroot");
2200 $label_maxroot->set_alignment (1, 0.5);
2201 $grid->attach($label_maxroot, 0, $row, 1, 1);
2203 my $entry_maxroot = Gtk3
::Entry-
>new();
2204 $entry_maxroot->set_tooltip_text("maximum size (GB) for LVM root volume");
2205 $entry_maxroot->signal_connect (key_press_event
=> \
&check_float
);
2206 $entry_maxroot->set_text($config_options->{maxroot
}) if $config_options->{maxroot
};
2207 $grid->attach($entry_maxroot, 1, $row, 1, 1);
2210 my $label_minfree = Gtk3
::Label-
>new ("minfree");
2211 $label_minfree->set_alignment (1, 0.5);
2212 $grid->attach($label_minfree, 0, $row, 1, 1);
2214 my $entry_minfree = Gtk3
::Entry-
>new();
2215 $entry_minfree->set_tooltip_text("minumum free LVM space (GB, required for LVM snapshots)");
2216 $entry_minfree->signal_connect (key_press_event
=> \
&check_float
);
2217 $entry_minfree->set_text($config_options->{minfree
}) if $config_options->{minfree
};
2218 $grid->attach($entry_minfree, 1, $row, 1, 1);
2221 my $label_maxvz = Gtk3
::Label-
>new ("maxvz");
2222 $label_maxvz->set_alignment (1, 0.5);
2223 $grid->attach($label_maxvz, 0, $row, 1, 1);
2225 my $entry_maxvz = Gtk3
::Entry-
>new();
2226 $entry_maxvz->set_tooltip_text("maximum size (GB) for LVM data volume");
2227 $entry_maxvz->signal_connect (key_press_event
=> \
&check_float
);
2228 $entry_maxvz->set_text($config_options->{maxvz
}) if $config_options->{maxvz
};
2229 $grid->attach($entry_maxvz, 1, $row, 1, 1);
2232 my $set_sensitive_flag = sub {
2233 my $enable_size_hints = $config_options->{filesys
} !~ m/zfs/;
2235 if ($config_options->{filesys
} =~ m/zfs/) {
2236 $target_hd_combo->set_visible(0);
2237 $target_hd_label->set_text("Target: $config_options->{filesys} ");
2238 foreach my $w (@disk_selector) { $w->set_visible(1); }
2239 foreach my $w (@disk_label) { $w->set_visible(1); }
2241 $target_hd_combo->set_visible(1);
2242 foreach my $w (@disk_selector) { $w->set_visible(0); }
2243 foreach my $w (@disk_label) { $w->set_visible(0); }
2244 $target_hd_label->set_text("Target Harddisk: ");
2247 $spinbutton_hdsize->set_visible($enable_size_hints);
2248 $label_hdsize->set_visible($enable_size_hints);
2249 $entry_swapsize->set_visible($enable_size_hints);
2250 $label_swapsize->set_visible($enable_size_hints);
2251 $entry_maxroot->set_visible($enable_size_hints);
2252 $label_maxroot->set_visible($enable_size_hints);
2253 $entry_minfree->set_visible($enable_size_hints);
2254 $label_minfree->set_visible($enable_size_hints);
2255 $entry_maxvz->set_visible($enable_size_hints);
2256 $label_maxvz->set_visible($enable_size_hints);
2259 &$set_sensitive_flag();
2261 $fstypecb->signal_connect (changed
=> sub {
2262 $config_options->{filesys
} = $fstypecb->get_active_text();
2263 &$set_sensitive_flag();
2270 my $get_float = sub {
2273 my $text = $entry->get_text();
2274 return undef if !defined($text);
2279 return undef if $text !~ m/^\d+(\.\d+)?$/;
2286 if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
2287 $config_options->{hdsize
} = $tmp;
2289 delete $config_options->{hdsize
};
2292 if (defined($tmp = &$get_float($entry_swapsize))) {
2293 $config_options->{swapsize
} = $tmp;
2295 delete $config_options->{swapsize
};
2298 if (defined($tmp = &$get_float($entry_maxroot))) {
2299 $config_options->{maxroot
} = $tmp;
2301 delete $config_options->{maxroot
};
2304 if (defined($tmp = &$get_float($entry_minfree))) {
2305 $config_options->{minfree
} = $tmp;
2307 delete $config_options->{minfree
};
2310 if (defined($tmp = &$get_float($entry_maxvz))) {
2311 $config_options->{maxvz
} = $tmp;
2313 delete $config_options->{maxvz
};
2319 sub get_zfs_raid_setup
{
2321 my $filesys = $config_options->{filesys
};
2323 my $dev_name_hash = {};
2326 my $bootdevlist = [];
2327 for (my $i = 0; $i < 8; $i++) {
2328 if (my $hd = $config_options->{"disksel$i"}) {
2329 my ($disk, $devname, $size, $model) = @$hd;
2330 die "device '$devname' is used more than once\n"
2331 if $dev_name_hash->{$devname};
2332 $dev_name_hash->{$devname} = $hd;
2333 push @$devlist, $hd;
2337 my $diskcount = scalar(@$devlist);
2338 die "$filesys need at least one device\n" if $diskcount < 1;
2341 if ($filesys eq 'zfs (RAID0)') {
2342 push @$bootdevlist, @$devlist[0];
2343 foreach my $hd (@$devlist) {
2346 } elsif ($filesys eq 'zfs (RAID1)') {
2347 die "zfs (RAID1) need at least 2 device\n" if $diskcount < 2;
2349 my $hd = @$devlist[0];
2350 my $expected_size = @$hd[2]; # all disks needs same size
2351 foreach $hd (@$devlist) {
2352 die "mirrored disks must have same size\n" if @$hd[2] != $expected_size;
2354 push @$bootdevlist, $hd;
2356 } elsif ($filesys eq 'zfs (RAID10)') {
2357 my $half = int($diskcount/2);
2358 die "zfs (RAID10) need at least 4 device\n" if $diskcount < 4;
2359 die "zfs (RAID10) need at an even numver of devices\n" if $half*2 != $diskcount;
2361 push @$bootdevlist, @$devlist[0], @$devlist[1];
2363 for (my $i = 0; $i < $diskcount; $i+=2) {
2364 my $hd1 = @$devlist[$i];
2365 my $hd2 = @$devlist[$i+1];
2366 die "mirrored disks must have same size\n" if @$hd1[2] != @$hd2[2];
2367 $cmd .= ' mirror ' . @$hd1[1] . ' ' . @$hd2[1];
2370 } elsif ($filesys =~ m/^zfs \(RAIDZ-([123])\)$/) {
2372 my $mindisks = 2 + $level;
2373 die "zfs (RAIDZ-$level) need at least $mindisks devices\n" if scalar(@$devlist) < $mindisks;
2374 my $hd = @$devlist[0];
2375 my $expected_size = @$hd[2]; # all disks needs same size
2376 $cmd .= " raidz$level";
2377 foreach $hd (@$devlist) {
2378 die "mirrored disks must have same size\n" if @$hd[2] != $expected_size;
2380 push @$bootdevlist, $hd;
2383 die "unknown zfs mode '$filesys'\n";
2386 return ($devlist, $bootdevlist, $cmd);
2389 sub create_hdsel_view
{
2393 my $vbox = Gtk3
::VBox-
>new (0, 0);
2394 $inbox->pack_start ($vbox, 1, 0, 0);
2395 my $hbox = Gtk3
::HBox-
>new (0, 0);
2396 $vbox->pack_start ($hbox, 0, 0, 10);
2398 my ($disk, $devname, $size, $model) = @{@$hds[0]};
2399 $target_hd = $devname;
2401 $target_hd_label = Gtk3
::Label-
>new ("Target Harddisk: ");
2402 $hbox->pack_start ($target_hd_label, 0, 0, 0);
2404 $target_hd_combo = Gtk3
::ComboBoxText-
>new();
2406 foreach my $hd (@$hds) {
2407 ($disk, $devname, $size, $model) = @$hd;
2408 $target_hd_combo->append_text (get_device_desc
($devname, $size, $model));
2411 $target_hd_combo->set_active (0);
2412 $target_hd_combo->signal_connect (changed
=> sub {
2413 $a = shift-
>get_active;
2414 my ($disk, $devname) = @{@$hds[$a]};
2415 $target_hd = $devname;
2418 $hbox->pack_start ($target_hd_combo, 0, 0, 10);
2420 my $options = Gtk3
::Button-
>new ('_Options');
2421 $options->signal_connect (clicked
=> \
&create_hdoption_view
);
2422 $hbox->pack_start ($options, 0, 0, 0);
2427 display_html
("page1.htm");
2429 set_next
(undef, sub {
2431 if ($config_options->{filesys
} =~ m/zfs/) {
2432 eval { get_zfs_raid_setup
(); };
2434 display_message
("Warning: $err\n" .
2435 "Please fix ZFS setup first.");
2437 create_country_view
();
2440 create_country_view
();
2445 sub create_extract_view
{
2449 display_html
("extract1-license.htm");
2450 $next->set_sensitive (0);
2452 my $vbox = Gtk3
::VBox-
>new (0, 0);
2453 $inbox->pack_start ($vbox, 1, 0, 0);
2454 my $hbox = Gtk3
::HBox-
>new (0, 0);
2455 $vbox->pack_start ($hbox, 0, 0, 10);
2457 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
2458 $hbox->pack_start ($vbox2, 0, 0, 0);
2460 $progress_status = Gtk3
::Label-
>new ('');
2461 $vbox2->pack_start ($progress_status, 1, 1, 0);
2463 $progress = Gtk3
::ProgressBar-
>new;
2464 $progress->set_show_text(1);
2465 $progress->set_size_request (600, -1);
2467 $vbox2->pack_start ($progress, 0, 0, 0);
2471 my $tdir = $opt_testmode ?
"target" : "/target";
2473 my $base = $opt_testmode ?
"/pve/$release/install/pve-base.tar" : "/proxmox/pve-base.tar";
2475 eval { extract_data
($base, $tdir); };
2478 $next->set_sensitive (1);
2480 set_next
("_Reboot", sub { exit (0); } );
2483 display_html
("fail.htm");
2484 display_error
($err);
2487 display_html
("success.htm");
2491 sub create_intro_view
{
2495 display_html
("license.htm");
2497 set_next
("I a_gree", \
&create_hdsel_view
);
2500 $ipconf = get_ip_config
();
2502 $country = detect_country
() if $ipconf->{addr
} || $opt_testmode;;
2504 # read country, kmap and timezone infos
2505 $cmap = read_cmap
();
2507 create_main_window
();
2509 if (!defined ($hds) || (scalar (@$hds) <= 0)) {
2510 print "no hardisks found\n";
2511 display_html
("nohds.htm");
2512 set_next
("Reboot", sub { exit (0); } );
2515 foreach my $hd (@$hds) {
2516 my ($disk, $devname) = @$hd;
2517 next if $devname =~ m
|^/dev/md\d
+$|;
2518 print "found Disk$disk N:$devname\n";
2521 create_intro_view
();