]>
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'\n";
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' - $!\n";
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)\n" 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 sector 2048 to 128M
762 my $endsec = 128*1024*2 - 1;
763 push @$pcmd, "-n$pnum:2048:$endsec", "-t$pnum:EF00";
766 # Note: from 128M to end
767 push @$pcmd, "-n$pnum:128M:${restricted_hdsize_mb}", "-t$pnum:8E00";
769 push @$pcmd, $target_dev;
771 my $os_size = $hdsize - 128*1024;
773 syscmd($pcmd) == 0 ||
774 die "unable to partition harddisk '${target_dev}'\n";
776 return ($os_size, $osdev, $efibootdev);
779 # ZFS has this use_whole_disk concept, so we try to partition the same
780 # way as zfs does by default. There is room at start of disk to insert
781 # a grub boot partition. But adding a EFI ESP is not possible.
783 # Note: zfs people think this is just a waste of space an not
784 # required. Instead, you should put the ESP on another disk (log,
787 sub partition_bootable_zfs_disk {
788 my ($target_dev) = @_;
790 die "too dangerous" if $opt_testmode;
792 syscmd("sgdisk -Z ${target_dev}");
793 my $hdsize = hd_size($target_dev); # size in blocks (1024 bytes)
795 my $hdgb = int($hdsize/(1024*1024));
796 die "hardisk '$target_dev' too small (${hdsize}GB)\n" if $hdgb < 8;
798 # 1 - GRUB boot partition: 1M
799 # 2 - OS/Data partition
800 # 9 - ZFS reserved partition
802 my $grubbootdev = get_partition_dev($target_dev, 1);
803 my $osdev = get_partition_dev ($target_dev, 2);
805 my $pcmd = ['sgdisk', '-a1'];
808 push @$pcmd, "-n$pnum:34:2047", "-t$pnum:EF02";
811 push @$pcmd, "-n$pnum:-8M:0", "-t$pnum:BF07";
814 push @$pcmd, "-n$pnum:2048:0", "-t$pnum:BF01", '-c', "$pnum:zfs";
816 push @$pcmd, $target_dev;
818 my $os_size = $hdsize - 1024 - 1024*8;
820 syscmd($pcmd) == 0 ||
821 die "unable to partition harddisk '${target_dev}'\n";
823 return ($os_size, $osdev);
826 sub create_lvm_volumes {
827 my ($lvmdev, $os_size, $swap_size) = @_;
829 my $rootdev = '/dev/pve/root';
830 my $datadev = '/dev/pve/data';
831 my $swapfile = '/dev/pve/swap';
833 # we use --metadatasize 250k, which reseults in "pe_start = 512"
834 # so pe_start is aligned on a 128k boundary (advantage for SSDs)
835 syscmd ("/sbin/pvcreate --metadatasize 250k -y -ff $lvmdev") == 0 ||
836 die "unable to initialize physical volume $lvmdev\n";
837 syscmd ("/sbin/vgcreate pve $lvmdev") == 0 ||
838 die "unable to create volume group 'pve'\n";
840 my $hdgb = int($os_size/(1024*1024));
841 my $space = (($hdgb > 128) ? 16 : ($hdgb/8))*1024*1024;
844 if ($config_options->{maxroot}) {
845 $maxroot = $config_options->{maxroot};
850 my $rootsize = (($hdgb > ($maxroot*4)) ? $maxroot : $hdgb/4)*1024*1024;
852 my $rest = $os_size - $swap_size - $rootsize; # in KB
855 if ($config_options->{minfree}) {
856 $minfree = (($config_options->{minfree}*1024*1024) >= $rest ) ? $space :
857 $config_options->{minfree}*1024*1024 ;
862 $rest = $rest - $minfree;
864 if ($config_options->{maxvz}) {
865 $rest = (($config_options->{maxvz}*1024*1024) <= $rest) ?
866 $config_options->{maxvz}*1024*1024 : $rest;
869 syscmd ("/sbin/lvcreate -L${swap_size}K -nswap pve") == 0 ||
870 die "unable to create swap volume\n";
872 syscmd ("/sbin/lvcreate -L${rootsize}K -nroot pve") == 0 ||
873 die "unable to create root volume\n";
875 syscmd ("/sbin/lvcreate -L${rest}K -ndata pve") == 0 ||
876 die "unable to create data volume\n";
878 syscmd ("/sbin/lvconvert --yes --type thin-pool pve/data") == 0 ||
879 die "unable to create data thin-pool\n";
881 syscmd ("/sbin/vgchange -a y pve") == 0 ||
882 die "unable to activate volume group\n";
884 return ($rootdev, $datadev, $swapfile);
887 sub compute_swapsize {
890 my $hdgb = int($hdsize/(1024*1024));
893 if ($config_options->{swapsize}) {
894 $swapsize = $config_options->{swapsize}*1024*1024;
896 my $ss = int ($total_memory / 1024);
898 $ss = ($hdgb/8) if $ss > ($hdgb/8);
900 $swapsize = $ss*1024*1024;
905 my ($tgzfile, $targetdir) = @_;
907 die "target '$targetdir' does not exist\n" if ! -d $targetdir;
909 my $bootdevinfo = [];
917 my $filesys = $config_options->{filesys};
919 if ($filesys =~ m/zfs/) {
920 $target_hd = undef; # do not use this config
922 $targetdir = "/$zfspoolname/ROOT/pve-1";
929 for ($i = 5; $i > 0; $i--) {
930 syscmd("modprobe zfs");
931 last if -c "/dev/zfs";
935 die "unable to load zfs kernel module\n" if !$i;
943 update_progress (0, 0, $maxper, "create partitions");
947 $rootdev = abs_path($target_hd);
948 syscmd ("umount $rootdev");
952 die "unsupported zfs mode (for testing environment)\n"
953 if $filesys ne 'zfs (RAID0)';
955 syscmd ("zpool destroy $zfspoolname") if $opt_testmode;
957 zfs_create_rpool($rootdev);
962 my ($devlist, $bootdevlist, $vdev) = get_zfs_raid_setup();
965 foreach my $hd (@$bootdevlist) {
966 my $devname = @$hd[1];
968 partition_bootable_zfs_disk($devname);
969 die "unable to mirror disks with different sizes!\n"
970 if $disksize && ($size != $disksize);
971 push @$bootdevinfo, { devname => $devname, osdev => $osdev};
975 sleep(1); # give kernel time to reread part table
977 # trigger udev to create /dev/disk/by-uuid
978 syscmd ("udevadm trigger --subsystem-match block");
979 syscmd ("udevadm settle --timeout 10");
981 foreach my $di (@$bootdevinfo) {
982 my $devname = $di->{devname};
983 $di->{by_id} = find_stable_path ("/dev/disk/by-id", $devname);
985 # Note: using /dev/disk/by-id/ does not work for unknown reason, we get
986 # cannot create 'rpool': no such pool or dataset
987 #my $osdev = find_stable_path ("/dev/disk/by-id", $di->{osdev}) || $di->{osdev};
989 my $osdev = $di->{osdev};
990 $vdev =~ s/ $devname/ $osdev/;
993 zfs_create_rpool($vdev);
995 my $swap_size = compute_swapsize($disksize);
996 $swapfile = zfs_create_swap($swap_size);
1000 die "target '$target_hd' is not a valid block device\n" if ! -b $target_hd;
1003 if ($config_options->{hdsize}) {
1004 # max hdsize passed on cmdline (GB)
1005 $maxhdsize = $config_options->{hdsize}*1024*1024;
1008 my ($os_size, $osdev, $efidev);
1009 ($os_size, $osdev, $efidev) =
1010 partition_bootable_disk($target_hd, $maxhdsize);
1012 sleep(1); # give kernel time to reread part table
1014 # trigger udev to create /dev/disk/by-uuid
1015 syscmd ("udevadm trigger --subsystem-match block");
1016 syscmd ("udevadm settle --timeout 10");
1018 my $by_id = find_stable_path ("/dev/disk/by-id", $target_hd);
1019 push @$bootdevinfo, { esp => $efidev, devname => $target_hd,
1020 osdev => $osdev, by_id => $by_id };
1022 my $swap_size = compute_swapsize($os_size);
1023 ($rootdev, $datadev, $swapfile) =
1024 create_lvm_volumes($osdev, $os_size, $swap_size);
1026 # trigger udev to create /dev/disk/by-uuid
1027 syscmd ("udevadm trigger --subsystem-match block");
1028 syscmd ("udevadm settle --timeout 10");
1032 # to be fast during installation
1033 syscmd ("zfs set sync=disabled $zfspoolname") == 0 ||
1034 die "unable to set zfs properties\n";
1037 update_progress (0.03, 0, $maxper, "create swap space");
1039 syscmd ("mkswap -f $swapfile") == 0 ||
1040 die "unable to create swap space\n";
1043 update_progress (0.05, 0, $maxper, "creating filesystems");
1045 foreach my $di (@$bootdevinfo) {
1046 next if !$di->{esp};
1047 syscmd ("mkfs.vfat -F32 $di->{esp}") == 0 ||
1048 die "unable to initialize EFI ESP on device $di->{esp}\n";
1053 if ( -b $target_hd) {
1055 create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1);
1059 create_filesystem ($rootdev, 'root', $filesys, 0.05, $maxper, 0, 1);
1063 update_progress (1, 0.05, $maxper, "mounting target $rootdev");
1066 syscmd ("mount -n $rootdev -o noatime,barrier=0 $targetdir") == 0 ||
1067 die "unable to mount $rootdev\n";
1070 mkdir "$targetdir/boot";
1071 mkdir "$targetdir/boot/efi";
1073 mkdir "$targetdir/var";
1074 mkdir "$targetdir/var/lib";
1075 mkdir "$targetdir/var/lib/vz";
1077 display_html ("extract2-rulesystem.htm");
1078 update_progress (1, 0.05, $maxper, "extracting base system");
1080 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat ($tgzfile);
1081 $ino || die "unable to open file '$tgzfile' - $!\n";
1084 if ($opt_testmode) {
1085 $files = file_read_firstline("/pve/$release/install/pve-base.cnt");
1087 $files = file_read_firstline("/proxmox/pve-base.cnt");
1093 run_command ("tar xvf $tgzfile -C $targetdir", sub {
1096 my $nper = int (($count *100)/$files);
1097 if ($nper != $per) {
1099 my $frac = $per > 100 ? 100 : $per/100;
1100 update_progress ($frac, $maxper, 0.5);
1104 syscmd ("mount -n -t tmpfs tmpfs $targetdir/tmp") == 0 ||
1105 die "unable to mount tmpfs on $targetdir/tmp\n";
1106 syscmd ("mount -n -t proc proc $targetdir/proc") == 0 ||
1107 die "unable to mount proc on $targetdir/proc\n";
1108 syscmd ("mount -n -t sysfs sysfs $targetdir/sys") == 0 ||
1109 die "unable to mount sysfs on $targetdir/sys\n";
1111 display_html ("extract3-spam.htm");
1112 update_progress (1, $maxper, 0.5, "configuring base system");
1117 "127.0.0.1 localhost.localdomain localhost\n" .
1118 "$ipaddress $hostname.$domain $hostname pvelocalhost\n\n" .
1119 "# The following lines are desirable for IPv6 capable hosts\n\n" .
1120 "::1 ip6-localhost ip6-loopback\n" .
1121 "fe00::0 ip6-localnet\n" .
1122 "ff00::0 ip6-mcastprefix\n" .
1123 "ff02::1 ip6-allnodes\n" .
1124 "ff02::2 ip6-allrouters\n" .
1125 "ff02::3 ip6-allhosts\n";
1127 write_config ($hosts, "$targetdir/etc/hosts");
1129 write_config ("$hostname\n", "$targetdir/etc/hostname");
1131 syscmd ("/bin/hostname $hostname") if !$opt_testmode;
1133 # configure interfaces
1135 my $ifaces = "auto lo\niface lo inet loopback\n\n";
1137 my $ntype = $ipversion == 4 ? 'inet' : 'inet6';
1140 "auto vmbr0\niface vmbr0 $ntype static\n" .
1141 "\taddress $ipaddress\n" .
1142 "\tnetmask $netmask\n" .
1143 "\tgateway $gateway\n" .
1144 "\tbridge_ports eth0\n" .
1145 "\tbridge_stp off\n" .
1148 write_config ($ifaces, "$targetdir/etc/network/interfaces");
1152 my $resolfconf = "search $domain\nnameserver $dnsserver\n";
1153 write_config ($resolfconf, "$targetdir/etc/resolv.conf");
1157 my $fstab = "# <file system> <mount point> <type> <options> <dump> <pass>\n";
1160 my $root_mountopt = $fssetup->{$filesys}->{root_mountopt} || 'defaults';
1161 $fstab .= "$rootdev / $filesys ${root_mountopt} 0 1\n";
1165 # Note: this is required by current grub, but really dangerous, because
1166 # vfat does not have journaling, so it triggers manual fsck after each crash
1167 # so we only mount /boot/efi if really required (efi systems).
1168 if ($grub_plattform =~ m/^efi-/) {
1169 if (scalar(@$bootdevinfo)) {
1170 my $di = @$bootdevinfo[0]; # simply use first disk
1172 my $efi_boot_uuid = $di->{esp};
1173 if (my $uuid = find_dev_by_uuid ($di->{esp})) {
1174 $efi_boot_uuid = "UUID=$uuid";
1177 $fstab .= "${efi_boot_uuid} /boot/efi vfat defaults 0 1\n";
1183 $fstab .= "$swapfile none swap sw 0 0\n" if $swapfile;
1185 $fstab .= "proc /proc proc defaults 0 0\n";
1187 write_config ($fstab, "$targetdir/etc/fstab");
1188 write_config ("", "$targetdir/etc/mtab");
1190 syscmd ("cp ${proxmox_dir}/policy-disable-rc.d " .
1191 "$targetdir/usr/sbin/policy-rc.d") == 0 ||
1192 die "unable to copy policy-rc.d\n";
1193 syscmd ("cp ${proxmox_dir}/fake-start-stop-daemon " .
1194 "$targetdir/sbin/") == 0 ||
1195 die "unable to copy start-stop-daemon\n";
1197 diversion_add ($targetdir, "/sbin/start-stop-daemon", "/sbin/fake-start-stop-daemon");
1198 diversion_add ($targetdir, "/usr/sbin/update-grub", "/bin/true");
1199 diversion_add ($targetdir, "/usr/sbin/update-initramfs", "/bin/true");
1201 syscmd ("touch $targetdir/proxmox_install_mode");
1203 my $grub_install_devices_txt = '';
1204 foreach my $di (@$bootdevinfo) {
1205 $grub_install_devices_txt .= ', ' if $grub_install_devices_txt;
1206 $grub_install_devices_txt .= $di->{by_id} || $di->{devname};
1209 # Note: debian-installer/locale is used by console-setup
1211 debconfig_set ($targetdir, <<_EOD);
1212 locales locales/default_environment_locale select en_US.UTF-8
1213 locales locales/locales_to_be_generated select en_US.UTF-8 UTF-8
1214 samba-common samba-common/dhcp boolean false
1215 samba-common samba-common/workgroup string WORKGROUP
1216 postfix postfix/main_mailer_type select Local only
1217 keyboard-configuration keyboard-configuration/xkb-keymap select $keymap
1218 d-i debian-installer/locale select en_US.UTF-8
1219 grub-pc grub-pc/install_devices select $grub_install_devices_txt
1222 my $pkgdir = $opt_testmode ?
"packages" : "/proxmox/packages";
1224 while (<$pkgdir/*.deb
>) { $pkg_count++ };
1227 while (<$pkgdir/*.deb
>) {
1230 my ($deb) = $path =~ m/$pkgdir\/(.*\
.deb
)/;
1231 # if ($deb =~ m/^grub-efi-/ && $deb !~ m/^grub-${grub_plattform}/) {
1235 update_progress
($count/$pkg_count, 0.5, 0.75, "extracting $deb");
1236 print "extracting: $deb\n";
1237 syscmd
("cp $path $targetdir/tmp/$deb") == 0 ||
1238 die "installation of package $deb failed\n";
1239 syscmd
("chroot $targetdir dpkg --force-depends --no-triggers --unpack /tmp/$deb") == 0 ||
1240 die "installation of package $deb failed\n";
1241 update_progress
((++$count)/$pkg_count, 0.5, 0.75);
1244 display_html
("extract4-virus.htm");
1246 my $cmd = "chroot $targetdir dpkg --force-confold --configure -a";
1248 run_command
($cmd, sub {
1250 if ($line =~ m/Setting up\s+(\S+)/) {
1251 update_progress
((++$count)/$pkg_count, 0.75, 0.95,
1256 debconfig_set
($targetdir, <<_EOD);
1257 postfix postfix/main_mailer_type select No configuration
1260 unlink "$targetdir/etc/mailname";
1261 $postfix_main_cf =~ s/__FQDN__/${hostname}.${domain}/;
1262 write_config
($postfix_main_cf, "$targetdir/etc/postfix/main.cf");
1264 # make sure we have all postfix directories
1265 syscmd
("chroot $targetdir /usr/sbin/postfix check");
1266 # cleanup mail queue
1267 syscmd
("chroot $targetdir /usr/sbin/postsuper -d ALL");
1269 # enable NTP (timedatectl set-ntp true does not work without DBUS)
1270 syscmd
("chroot $targetdir /bin/systemctl enable systemd-timesyncd.service");
1272 unlink "$targetdir/proxmox_install_mode";
1275 unlink ("$targetdir/etc/localtime");
1276 symlink ("/usr/share/zoneinfo/$timezone", "$targetdir/etc/localtime");
1277 write_config
("$timezone\n", "$targetdir/etc/timezone");
1280 if (my $mirror = $cmap->{country
}->{$country}->{mirror
}) {
1281 my $fn = "$targetdir/etc/apt/sources.list";
1282 syscmd
("sed -i 's/ftp\\.debian\\.org/$mirror/' '$fn'");
1285 # create extended_states for apt (avoid cron job warning if that
1286 # file does not exist)
1287 write_config
('', "$targetdir/var/lib/apt/extended_states");
1289 # allow ssh root login
1290 syscmd
("sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' '$targetdir/etc/ssh/sshd_config'");
1292 # save installer settings
1293 my $ucc = uc ($country);
1294 debconfig_set
($targetdir, <<_EOD);
1295 pve-manager pve-manager/country string $ucc
1298 update_progress
(0.8, 0.95, 1, "make system bootable");
1301 syscmd
("sed -i -e 's/^GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"root=ZFS=$zfspoolname\\/ROOT\\/pve-1 boot=zfs\"/' $targetdir/etc/default/grub") == 0 ||
1302 die "unable to update /etc/default/grub\n";
1306 diversion_remove
($targetdir, "/usr/sbin/update-grub");
1307 diversion_remove
($targetdir, "/usr/sbin/update-initramfs");
1309 if (!$opt_testmode) {
1311 unlink ("$targetdir/etc/mtab");
1312 symlink ("/proc/mounts", "$targetdir/etc/mtab");
1313 syscmd
("mount -n --bind /dev $targetdir/dev");
1315 syscmd
("chroot $targetdir /usr/sbin/update-initramfs -c -k $kapi") == 0 ||
1316 die "unable to install initramfs\n";
1318 foreach my $di (@$bootdevinfo) {
1319 my $dev = $di->{devname
};
1320 syscmd
("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
1321 die "unable to install the i386-pc boot loader on '$dev'\n";
1324 syscmd
("mount -n $di->{esp} $targetdir/boot/efi") == 0 ||
1325 die "unable to mount $di->{esp}\n";
1326 syscmd
("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
1327 die "unable to install the EFI boot loader on '$dev'\n";
1328 # also install fallback boot file (OVMF does not boot without)
1329 mkdir("$targetdir/boot/efi/EFI/BOOT");
1330 syscmd
("cp $targetdir/boot/efi/EFI/proxmox/grubx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.EFI") == 0 ||
1331 die "unable to copy efi boot loader\n";
1333 syscmd
("umount $targetdir/boot/efi") == 0 ||
1334 die "unable to umount $targetdir/boot/efi\n";
1338 syscmd
("chroot $targetdir /usr/sbin/update-grub") == 0 ||
1339 die "unable to update boot loader config\n";
1341 syscmd
("umount $targetdir/dev");
1346 # hack: remove dead.letter from sshd installation
1347 syscmd
("rm -rf $targetdir/dead.letter");
1349 unlink "$targetdir/usr/sbin/policy-rc.d";
1351 diversion_remove
($targetdir, "/sbin/start-stop-daemon");
1354 my $octets = encode
("utf-8", $password);
1355 run_command
("chroot $targetdir /usr/sbin/chpasswd", undef,
1360 my $tmpdir = "$targetdir/tmp/pve";
1363 # write vnc keymap to datacenter.cfg
1364 my $vnckmap = $cmap->{kmap
}->{$keymap}->{kvm
} || 'en-us';
1365 write_config
("keyboard: $vnckmap\n",
1366 "$tmpdir/datacenter.cfg");
1369 write_config
("user:root\@pam:1:0:::${mailto}::\n",
1370 "$tmpdir/user.cfg");
1373 my $strorage_cfg_fn = "$tmpdir/storage.cfg";
1375 write_config
($storage_cfg_zfs, $strorage_cfg_fn);
1377 write_config
($storage_cfg_lvmthin, $strorage_cfg_fn);
1380 run_command
("chroot $targetdir /usr/bin/create_pmxcfs_db /tmp/pve /var/lib/pve-cluster/config.db");
1382 syscmd
("rm -rf $tmpdir");
1387 update_progress
(1, 0, 1, "");
1391 if ($opt_testmode) {
1392 syscmd
("chroot $targetdir /usr/bin/dpkg-query -W --showformat='\${package}\n'> pve-final.pkglist");
1395 syscmd
("umount $targetdir/var/lib/vz");
1396 syscmd
("umount $targetdir/tmp");
1397 syscmd
("umount $targetdir/proc");
1398 syscmd
("umount $targetdir/sys");
1401 syscmd
("zfs umount -a") == 0 ||
1402 die "unable to unmount zfs\n";
1404 syscmd
("umount -d $targetdir");
1407 if (!$err && $use_zfs) {
1408 syscmd
("zfs set sync=standard $zfspoolname") == 0 ||
1409 die "unable to set zfs properties\n";
1411 syscmd
("zfs set mountpoint=/ $zfspoolname/ROOT/pve-1") == 0 ||
1412 die "zfs set mountpoint failed\n";
1414 syscmd
("zpool set bootfs=$zfspoolname/ROOT/pve-1 $zfspoolname") == 0 ||
1415 die "zfs set bootfs failed\n";
1422 my ($filename) = @_;
1424 my $path = "${proxmox_dir}/html/$filename";
1425 my $url = "file://$path";
1427 my $data = file_get_contents
($path);
1429 if ($filename eq 'license.htm') {
1430 my $licensefn = -f
"/EULA" ?
"/EULA" :
1431 $opt_testmode ?
"./copyright" :
1432 "/usr/share/doc/pve-installer/copyright";
1433 my $license = decode
('utf8', file_get_contents
($licensefn));
1434 $license =~ m/^\s+(.+\n)/;
1435 my $title = $licensefn eq '/EULA' ?
"END USER LICENSE AGREEMENT (EULA)": $1;
1436 $data =~ s/__LICENSE__/$license/;
1437 $data =~ s/__LICENSE_TITLE__/$title/;
1440 $htmlview->load_html_string($data, $url);
1444 my ($text, $fctn) = @_;
1447 $text = "_Next" if !$text;
1448 $next->set_label ($text);
1450 $next->grab_focus ();
1454 my ($doc, $url, $stream) = @_;
1456 $stream->set_cancel_func (sub {}); # hack: avoid warning
1458 my $path = "${proxmox_dir}/html/$url";
1461 open (HTMLTMP
, $path) ||
1462 die "unable to open file '$path' - $!\n";
1464 while (my $i = read (HTMLTMP
, $buf, 4096)) {
1465 $stream->write ($buf);
1466 Gtk3
::main_iteration
() while Gtk3
::events_pending
();
1471 #$stream->close(); # hack: dont close - avoid crash
1474 sub create_main_window
{
1476 $window = Gtk3
::Window-
>new ();
1477 $window->set_default_size (1024, 768);
1478 $window->set_has_resize_grip(0);
1479 $window->set_decorated (0) if !$opt_testmode;
1481 my $vbox = Gtk3
::VBox-
>new (0, 0);
1483 my $image = Gtk3
::Image-
>new_from_file ("${proxmox_dir}/proxlogo.png");
1484 $vbox->pack_start ($image, 0, 0, 0);
1486 my $hbox = Gtk3
::HBox-
>new (0, 0);
1487 $vbox->pack_start ($hbox, 1, 1, 0);
1489 # my $f1 = Gtk3::Frame->new ('test');
1490 # $f1->set_shadow_type ('none');
1491 # $hbox->pack_start ($f1, 1, 1, 0);
1493 my $sep1 = Gtk3
::HSeparator-
>new;
1494 $vbox->pack_start ($sep1, 0, 0, 0);
1496 $cmdbox = Gtk3
::HBox-
>new ();
1497 $vbox->pack_start ($cmdbox, 0, 0, 10);
1499 $next = Gtk3
::Button-
>new ('_Next');
1500 $next->signal_connect (clicked
=> sub { &$next_fctn (); });
1501 $cmdbox->pack_end ($next, 0, 0, 10);
1502 my $abort = Gtk3
::Button-
>new ('_Abort');
1503 $abort->set_can_focus (0);
1504 $cmdbox->pack_start ($abort, 0, 0, 10);
1505 $abort->signal_connect (clicked
=> sub { exit (-1); });
1507 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1508 $hbox->add ($vbox2);
1510 $htmlview = Gtk3
::WebKit
::WebView-
>new();
1511 my $scrolls = Gtk3
::ScrolledWindow-
>new();
1512 $scrolls->add($htmlview);
1514 my $hbox2 = Gtk3
::HBox-
>new (0, 0);
1515 $hbox2->pack_start ($scrolls, 1, 1, 0);
1517 $vbox2->pack_start ($hbox2, 1, 1, 0);
1519 my $vbox3 = Gtk3
::VBox-
>new (0, 0);
1520 $vbox2->pack_start ($vbox3, 0, 0, 0);
1522 my $sep2 = Gtk3
::HSeparator-
>new;
1523 $vbox3->pack_start ($sep2, 0, 0, 0);
1525 $inbox = Gtk3
::HBox-
>new (0, 0);
1526 $vbox3->pack_start ($inbox, 0, 0, 0);
1528 $window->add ($vbox);
1531 $window->realize ();
1535 $inbox->foreach(sub {
1537 $inbox->remove ($child);
1541 # fixme: newer GTK3 has special properties to handle numbers with Entry
1542 # only allow floating point numbers with Gtk3::Entry
1544 my ($entry, $event) = @_;
1547 my $val = $event->get_keyval;
1549 if ($val == ord '.' ||
1550 $val == Gtk3
::Gdk
::KEY_ISO_Left_Tab
||
1551 $val == Gtk3
::Gdk
::KEY_Shift_L
||
1552 $val == Gtk3
::Gdk
::KEY_Tab
||
1553 $val == Gtk3
::Gdk
::KEY_Left
||
1554 $val == Gtk3
::Gdk
::KEY_Right
||
1555 $val == Gtk3
::Gdk
::KEY_BackSpace
||
1556 $val == Gtk3
::Gdk
::KEY_Delete
||
1557 ($val >= ord '0' && $val <= ord '9') ||
1558 ($val >= Gtk3
::Gdk
::KEY_KP_0
&&
1559 $val <= Gtk3
::Gdk
::KEY_KP_9
)) {
1566 sub create_text_input
{
1567 my ($default, $text) = @_;
1569 my $hbox = Gtk3
::HBox-
>new (0, 0);
1571 my $label = Gtk3
::Label-
>new ($text);
1572 $label->set_size_request (150, -1);
1573 $label->set_alignment (1, 0.5);
1574 $hbox->pack_start ($label, 0, 0, 10);
1575 my $e1 = Gtk3
::Entry-
>new ();
1576 $e1->set_width_chars (30);
1577 $hbox->pack_start ($e1, 0, 0, 0);
1578 $e1->set_text ($default);
1580 return ($hbox, $e1);
1585 my $ifconfig = `ifconfig eth0`;
1587 my ($addr) = $ifconfig =~ m/inet addr:(\S*)/m;
1588 my ($mask) = $ifconfig =~ m/Mask:(\S*)/m;
1590 my $route = `route -n`;
1591 my ($gateway) = $route =~ m/^0\.0\.0\.0\s+(\d+\.\d+\.\d+\.\d+)\s+/m;
1593 my $resolvconf = `cat /etc/resolv.conf`;
1594 my ($dnsserver) = $resolvconf =~ m/^nameserver\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/m;
1595 my ($domain) = $resolvconf =~ m/^domain\s+(\S+)$/m;
1600 gateway
=> $gateway,
1601 dnsserver
=> $dnsserver,
1606 sub display_message
{
1609 my $dialog = Gtk3
::MessageDialog-
>new ($window, 'modal',
1610 'info', 'ok', $msg);
1618 my $dialog = Gtk3
::MessageDialog-
>new ($window, 'modal',
1619 'error', 'ok', $msg);
1624 sub create_ipconf_view
{
1627 display_html
("ipconf.htm");
1629 my $vbox = Gtk3
::VBox-
>new (0, 0);
1630 $inbox->pack_start ($vbox, 1, 0, 0);
1631 my $hbox = Gtk3
::HBox-
>new (0, 0);
1632 $vbox->pack_start ($hbox, 0, 0, 10);
1633 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1634 $hbox->add ($vbox2);
1636 my $addr = $ipconf->{addr
} || '192.168.100.2';
1637 my $mask = $ipconf->{mask
} || '255.255.255.0';
1639 my $hn = $ipconf->{domain
} ?
"pve.$ipconf->{domain}" : 'pve.domain.tld';
1641 my ($hostbox, $hostentry) =
1642 create_text_input
($hn, 'Hostname (FQDN):');
1643 $vbox2->pack_start ($hostbox, 0, 0, 2);
1646 ($ipbox, $ipconf_entry_addr) =
1647 create_text_input
($addr, 'IP Address:');
1648 $vbox2->pack_start ($ipbox, 0, 0, 2);
1651 ($maskbox, $ipconf_entry_mask) =
1652 create_text_input
($mask, 'Netmask:');
1653 $vbox2->pack_start ($maskbox, 0, 0, 2);
1655 $gateway = $ipconf->{gateway
} || '192.168.100.1';
1658 ($gwbox, $ipconf_entry_gw) =
1659 create_text_input
($gateway, 'Gateway:');
1661 $vbox2->pack_start ($gwbox, 0, 0, 2);
1663 $dnsserver = $ipconf->{dnsserver
} || $gateway;
1666 ($dnsbox, $ipconf_entry_dns) =
1667 create_text_input
($dnsserver, 'DNS Server:');
1669 $vbox2->pack_start ($dnsbox, 0, 0, 0);
1672 set_next
(undef, sub {
1676 my $text = $hostentry->get_text();
1681 my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
1683 # Debian does not support purely numeric hostnames
1684 if ($text && $text =~ /^[0-9]+(?:\.|$)/) {
1685 display_message
("Purely numeric hostnames are not allowed.");
1686 $hostentry->grab_focus();
1690 if ($text && $text =~ m/^(${namere}\.)*${namere}$/ && $text !~ m/.domain.tld$/ &&
1691 $text =~ m/^([^\.]+)\.(\S+)$/) {
1695 display_message
("Hostname does not look like a fully qualified domain name.");
1696 $hostentry->grab_focus();
1702 $text = $ipconf_entry_addr->get_text();
1705 if ($text =~ m!^($IPV4RE)$!) {
1708 } elsif ($text =~ m!^($IPV6RE)$!) {
1712 display_message
("IP address is not valid.");
1713 $ipconf_entry_addr->grab_focus();
1717 $text = $ipconf_entry_mask->get_text();
1720 if (($ipversion == 6) && ($text =~ m/^(\d+)$/) && ($1 >= 8) && ($1 <= 126)) {
1722 } elsif (($ipversion == 4) && defined($ipv4_mask_hash->{$text})) {
1725 display_message
("Netmask is not valid.");
1726 $ipconf_entry_mask->grab_focus();
1730 $text = $ipconf_entry_gw->get_text();
1733 if (($ipversion == 4) && ($text =~ m!^($IPV4RE)$!)) {
1735 } elsif (($ipversion == 6) && ($text =~ m!^($IPV6RE)$!)) {
1738 display_message
("Gateway is not valid.");
1739 $ipconf_entry_gw->grab_focus();
1743 $text = $ipconf_entry_dns->get_text();
1746 if (($ipversion == 4) && ($text =~ m!^($IPV4RE)$!)) {
1748 } elsif (($ipversion == 6) && ($text =~ m!^($IPV6RE)$!)) {
1751 display_message
("DNS server is not valid.");
1752 $ipconf_entry_dns->grab_focus();
1756 #print "TEST $ipaddress $netmask $gateway $dnsserver\n";
1758 create_extract_view
();
1761 $hostentry->grab_focus();
1764 sub get_device_desc
{
1765 my ($devname, $size, $model) = @_;
1767 if ($size && ($size > 0)) {
1768 $size = int($size/2048); # size in MB
1770 my $text = "$devname (";
1771 if ($size >= 1024) {
1772 $size = int($size/1024); # size in GB
1773 $text .= "${size}GB";
1775 $text .= "${size}MB";
1778 $text .= ", $model" if $model;
1787 my ($cb, $kmap) = @_;
1792 my $kmaphash = $cmap->{kmaphash
};
1793 foreach my $layout (sort keys %$kmaphash) {
1794 $def = $i if $kmaphash->{$layout} eq 'en-us';
1795 $ind = $i if $kmap && $kmaphash->{$layout} eq $kmap;
1799 $cb->set_active ($ind || $def || 0);
1803 sub update_zonelist
{
1804 my ($box, $cc) = @_;
1806 my $cczones = $cmap->{cczones
};
1807 my $zones = $cmap->{zones
};
1811 $sel = $lastzonecb->get_active_text();
1812 $box->remove ($lastzonecb);
1814 $sel = $timezone; # used once to select default
1817 my $cb = $lastzonecb = Gtk3
::ComboBoxText-
>new();
1818 $cb->set_size_request (200, -1);
1820 $cb->signal_connect ('changed' => sub {
1821 $timezone = $cb->get_active_text();
1825 if ($cc && defined ($cczones->{$cc})) {
1826 @za = keys %{$cczones->{$cc}};
1832 foreach my $zone (sort @za) {
1833 $ind = $i if $sel && $zone eq $sel;
1834 $cb->append_text ($zone);
1838 $cb->set_active ($ind || 0);
1841 $box->pack_start ($cb, 0, 0, 0);
1844 sub create_password_view
{
1848 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1849 $inbox->pack_start ($vbox2, 1, 0, 0);
1850 my $vbox = Gtk3
::VBox-
>new (0, 0);
1851 $vbox2->pack_start ($vbox, 0, 0, 10);
1853 my $hbox1 = Gtk3
::HBox-
>new (0, 0);
1854 my $label = Gtk3
::Label-
>new ("Password");
1855 $label->set_size_request (150, -1);
1856 $label->set_alignment (1, 0.5);
1857 $hbox1->pack_start ($label, 0, 0, 10);
1858 my $pwe1 = Gtk3
::Entry-
>new ();
1859 $pwe1->set_visibility (0);
1860 $pwe1->set_size_request (200, -1);
1861 $hbox1->pack_start ($pwe1, 0, 0, 0);
1863 my $hbox2 = Gtk3
::HBox-
>new (0, 0);
1864 $label = Gtk3
::Label-
>new ("Confirm");
1865 $label->set_size_request (150, -1);
1866 $label->set_alignment (1, 0.5);
1867 $hbox2->pack_start ($label, 0, 0, 10);
1868 my $pwe2 = Gtk3
::Entry-
>new ();
1869 $pwe2->set_visibility (0);
1870 $pwe2->set_size_request (200, -1);
1871 $hbox2->pack_start ($pwe2, 0, 0, 0);
1873 my $hbox3 = Gtk3
::HBox-
>new (0, 0);
1874 $label = Gtk3
::Label-
>new ("E-Mail");
1875 $label->set_size_request (150, -1);
1876 $label->set_alignment (1, 0.5);
1877 $hbox3->pack_start ($label, 0, 0, 10);
1878 my $eme = Gtk3
::Entry-
>new ();
1879 $eme->set_size_request (200, -1);
1880 $hbox3->pack_start ($eme, 0, 0, 0);
1883 $vbox->pack_start ($hbox1, 0, 0, 5);
1884 $vbox->pack_start ($hbox2, 0, 0, 5);
1885 $vbox->pack_start ($hbox3, 0, 0, 15);
1889 display_html
("passwd.htm");
1891 set_next
(undef, sub {
1893 my $t1 = $pwe1->get_text;
1894 my $t2 = $pwe2->get_text;
1896 if (length ($t1) < 5) {
1897 display_message
("Password is too short.");
1898 $pwe1->grab_focus();
1903 display_message
("Password does not match.");
1904 $pwe1->grab_focus();
1908 my $t3 = $eme->get_text;
1909 if ($t3 !~ m/^\S+\@\S+\.\S+$/) {
1910 display_message
("E-Mail does not look like a vaild address" .
1911 " (user\@domain.tld)");
1920 create_ipconf_view
();
1923 $pwe1->grab_focus();
1927 sub create_country_view
{
1931 my $countryhash = $cmap->{countryhash
};
1932 my $ctr = $cmap->{country
};
1934 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
1935 $inbox->pack_start ($vbox2, 1, 0, 0);
1936 my $vbox = Gtk3
::VBox-
>new (0, 0);
1937 $vbox2->pack_start ($vbox, 0, 0, 10);
1939 my $w = Gtk3
::Entry-
>new ();
1940 $w->set_size_request (200, -1);
1942 my $c = Gtk3
::EntryCompletion-
>new ();
1943 $c->set_text_column (0);
1944 $c->set_minimum_key_length(0);
1945 $c->set_popup_set_width (1);
1946 $c->set_inline_completion (1);
1948 my $hbox2 = Gtk3
::HBox-
>new (0, 0);
1949 my $label = Gtk3
::Label-
>new ("Time zone");
1950 $label->set_size_request (150, -1);
1951 $label->set_alignment (1, 0.5);
1952 $hbox2->pack_start ($label, 0, 0, 10);
1953 update_zonelist
($hbox2);
1955 my $hbox3 = Gtk3
::HBox-
>new (0, 0);
1956 $label = Gtk3
::Label-
>new ("Keyboard Layout");
1957 $label->set_size_request (150, -1);
1958 $label->set_alignment (1, 0.5);
1959 $hbox3->pack_start ($label, 0, 0, 10);
1961 my $kmapcb = Gtk3
::ComboBoxText-
>new();
1962 $kmapcb->set_size_request (200, -1);
1963 foreach my $layout (sort keys %{$cmap->{kmaphash
}}) {
1964 $kmapcb->append_text ($layout);
1967 update_layout
($kmapcb);
1968 $hbox3->pack_start ($kmapcb, 0, 0, 0);
1970 $kmapcb->signal_connect ('changed' => sub {
1971 my $sel = $kmapcb->get_active_text();
1972 if (my $kmap = $cmap->{kmaphash
}->{$sel}) {
1973 my $xkmap = $cmap->{kmap
}->{$kmap}->{x11
};
1974 my $xvar = $cmap->{kmap
}->{$kmap}->{x11var
};
1975 syscmd
("setxkbmap $xkmap $xvar") if !$opt_testmode;
1980 $w->signal_connect ('changed' => sub {
1981 my ($entry, $event) = @_;
1982 my $text = $entry->get_text;
1984 if (my $cc = $countryhash->{lc($text)}) {
1985 update_zonelist
($hbox2, $cc);
1986 my $kmap = $ctr->{$cc}->{kmap
} || 'en-us';
1987 update_layout
($kmapcb, $kmap);
1991 $w->signal_connect (key_press_event
=> sub {
1992 my ($entry, $event) = @_;
1993 my $text = $entry->get_text;
1995 my $val = $event->get_keyval;
1997 if ($val == Gtk3
::Gdk
::KEY_Tab
) {
1998 my $cc = $countryhash->{lc($text)};
2005 $compl = $ctr->{$cc}->{name
};
2007 foreach my $cc (keys %$ctr) {
2008 my $ct = $ctr->{$cc}->{name
};
2009 if ($ct =~ m/^\Q$text\E.*$/i) {
2018 $entry->set_text($compl);
2023 print chr(7); # beep ?
2028 my $buf = $w->get_buffer();
2029 $buf->insert_text(-1, '', -1); # popup selection
2037 my $ls = Gtk3
::ListStore-
>new('Glib::String');
2038 foreach my $cc (sort {$ctr->{$a}->{name
} cmp $ctr->{$b}->{name
} } keys %$ctr) {
2039 my $iter = $ls->append();
2040 $ls->set ($iter, 0, $ctr->{$cc}->{name
});
2042 $c->set_model ($ls);
2044 $w->set_completion ($c);
2046 my $hbox = Gtk3
::HBox-
>new (0, 0);
2048 $label = Gtk3
::Label-
>new ("Country");
2049 $label->set_alignment (1, 0.5);
2050 $label->set_size_request (150, -1);
2051 $hbox->pack_start ($label, 0, 0, 10);
2052 $hbox->pack_start ($w, 0, 0, 0);
2054 $vbox->pack_start ($hbox, 0, 0, 5);
2055 $vbox->pack_start ($hbox2, 0, 0, 5);
2056 $vbox->pack_start ($hbox3, 0, 0, 5);
2059 $w->set_text ($ctr->{$country}->{name
});
2064 display_html
("country.htm");
2065 set_next
(undef, sub {
2067 my $text = $w->get_text;
2069 if (my $cc = $countryhash->{lc($text)}) {
2071 create_password_view
();
2074 display_message
("Please select a country first.");
2082 my $target_hd_combo;
2083 my $target_hd_label;
2085 my $hdopion_first_setup = 1;
2087 sub create_hdoption_view
{
2089 my $dialog = Gtk3
::Dialog-
>new();
2091 $dialog->set_title("Harddisk options");
2093 $dialog->add_button("_OK", 1);
2095 my $contarea = $dialog->get_content_area();
2097 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
2098 $contarea->pack_start($hbox2, 1, 1, 10);
2100 my $grid = Gtk3
::Grid-
>new();
2101 $grid->set_column_spacing(10);
2102 $grid->set_row_spacing(10);
2104 $hbox2->pack_start($grid, 1, 0, 10);
2110 my $label0 = Gtk3
::Label-
>new ("Filesystem");
2111 $label0->set_alignment (1, 0.5);
2112 $grid->attach($label0, 0, $row, 1, 1);
2114 my $fstypecb = Gtk3
::ComboBoxText-
>new();
2116 my $fstype = ['ext3', 'ext4', 'xfs', 'zfs (RAID0)', 'zfs (RAID1)',
2117 'zfs (RAID10)', 'zfs (RAIDZ-1)',
2118 'zfs (RAIDZ-2)', 'zfs (RAIDZ-3)'];
2121 foreach my $tmp (@$fstype) {
2122 $fstypecb->append_text($tmp);
2123 $fstypecb->set_active ($tcount)
2124 if $config_options->{filesys
} eq $tmp;
2128 $grid->attach($fstypecb, 1, $row, 1, 1);
2136 for (my $i = 0; $i < 8; $i++) {
2137 $disk_label[$i] = Gtk3
::Label-
>new ("Hardisk $i");
2138 $disk_label[$i]->set_alignment (1, 0.5);
2139 $grid->attach($disk_label[$i], 0, $row, 1, 1);
2140 $disk_selector[$i] = Gtk3
::ComboBoxText-
>new();
2141 $disk_selector[$i]->append_text("-- do not use --");
2142 $disk_selector[$i]->set_active(0);
2143 foreach my $hd (@$hds) {
2144 my ($disk, $devname, $size, $model) = @$hd;
2145 $disk_selector[$i]->append_text(get_device_desc
($devname, $size, $model));
2146 $disk_selector[$i]->{pve_disk_id
} = $i;
2147 $disk_selector[$i]->signal_connect (changed
=> sub {
2149 my $diskid = $w->{pve_disk_id
};
2150 my $a = $w->get_active - 1;
2151 $config_options->{"disksel${diskid}"} = ($a >= 0) ?
$hds->[$a] : undef;
2155 if ($hdopion_first_setup) {
2156 $disk_selector[$i]->set_active ($i+1) if $hds->[$i];
2159 if (my $cur_hd = $config_options->{"disksel$i"}) {
2160 foreach my $hd (@$hds) {
2161 if (@$hd[1] eq @$cur_hd[1]) {
2162 $disk_selector[$i]->set_active($hdind+1);
2171 $grid->attach($disk_selector[$i], 1, $row, 1, 1);
2176 $hdopion_first_setup = 0;
2178 my $label_hdsize = Gtk3
::Label-
>new ("hdsize");
2179 $label_hdsize->set_alignment (1, 0.5);
2180 $grid->attach($label_hdsize, 0, $row, 1, 1);
2184 if ( -b
$target_hd) {
2185 $hdsize = int(hd_size
($target_hd) / (1024*1024.0)); # size in GB
2186 } elsif ($target_hd) {
2187 $hdsize = int((-s
$target_hd) / (1024*1024*1024.0));
2190 my $hdsize_size_adj = Gtk3
::Adjustment-
>new($config_options->{hdsize
} || $hdsize, 0, $hdsize+1, 1, 1, 1);
2191 my $spinbutton_hdsize = Gtk3
::SpinButton-
>new($hdsize_size_adj, 1, 1);
2192 $spinbutton_hdsize->set_tooltip_text("only use specified size (GB) of the harddisk (rest left unpartitioned)");
2193 $grid->attach($spinbutton_hdsize, 1, $row, 1, 1);
2196 my $label_swapsize = Gtk3
::Label-
>new ("swapsize");
2197 $label_swapsize->set_alignment (1, 0.5);
2198 $grid->attach($label_swapsize, 0, $row, 1, 1);
2200 my $entry_swapsize = Gtk3
::Entry-
>new();
2201 $entry_swapsize->set_tooltip_text("maximum SWAP size (GB)");
2202 $entry_swapsize->signal_connect (key_press_event
=> \
&check_float
);
2203 $entry_swapsize->set_text($config_options->{swapsize
}) if $config_options->{swapsize
};
2204 $grid->attach($entry_swapsize, 1, $row, 1, 1);
2207 my $label_maxroot = Gtk3
::Label-
>new ("maxroot");
2208 $label_maxroot->set_alignment (1, 0.5);
2209 $grid->attach($label_maxroot, 0, $row, 1, 1);
2211 my $entry_maxroot = Gtk3
::Entry-
>new();
2212 $entry_maxroot->set_tooltip_text("maximum size (GB) for LVM root volume");
2213 $entry_maxroot->signal_connect (key_press_event
=> \
&check_float
);
2214 $entry_maxroot->set_text($config_options->{maxroot
}) if $config_options->{maxroot
};
2215 $grid->attach($entry_maxroot, 1, $row, 1, 1);
2218 my $label_minfree = Gtk3
::Label-
>new ("minfree");
2219 $label_minfree->set_alignment (1, 0.5);
2220 $grid->attach($label_minfree, 0, $row, 1, 1);
2222 my $entry_minfree = Gtk3
::Entry-
>new();
2223 $entry_minfree->set_tooltip_text("minumum free LVM space (GB, required for LVM snapshots)");
2224 $entry_minfree->signal_connect (key_press_event
=> \
&check_float
);
2225 $entry_minfree->set_text($config_options->{minfree
}) if $config_options->{minfree
};
2226 $grid->attach($entry_minfree, 1, $row, 1, 1);
2229 my $label_maxvz = Gtk3
::Label-
>new ("maxvz");
2230 $label_maxvz->set_alignment (1, 0.5);
2231 $grid->attach($label_maxvz, 0, $row, 1, 1);
2233 my $entry_maxvz = Gtk3
::Entry-
>new();
2234 $entry_maxvz->set_tooltip_text("maximum size (GB) for LVM data volume");
2235 $entry_maxvz->signal_connect (key_press_event
=> \
&check_float
);
2236 $entry_maxvz->set_text($config_options->{maxvz
}) if $config_options->{maxvz
};
2237 $grid->attach($entry_maxvz, 1, $row, 1, 1);
2240 my $set_sensitive_flag = sub {
2241 my $enable_size_hints = $config_options->{filesys
} !~ m/zfs/;
2243 if ($config_options->{filesys
} =~ m/zfs/) {
2244 $target_hd_combo->set_visible(0);
2245 $target_hd_label->set_text("Target: $config_options->{filesys} ");
2246 foreach my $w (@disk_selector) { $w->set_visible(1); }
2247 foreach my $w (@disk_label) { $w->set_visible(1); }
2249 $target_hd_combo->set_visible(1);
2250 foreach my $w (@disk_selector) { $w->set_visible(0); }
2251 foreach my $w (@disk_label) { $w->set_visible(0); }
2252 $target_hd_label->set_text("Target Harddisk: ");
2255 $spinbutton_hdsize->set_visible($enable_size_hints);
2256 $label_hdsize->set_visible($enable_size_hints);
2257 $entry_swapsize->set_visible($enable_size_hints);
2258 $label_swapsize->set_visible($enable_size_hints);
2259 $entry_maxroot->set_visible($enable_size_hints);
2260 $label_maxroot->set_visible($enable_size_hints);
2261 $entry_minfree->set_visible($enable_size_hints);
2262 $label_minfree->set_visible($enable_size_hints);
2263 $entry_maxvz->set_visible($enable_size_hints);
2264 $label_maxvz->set_visible($enable_size_hints);
2267 &$set_sensitive_flag();
2269 $fstypecb->signal_connect (changed
=> sub {
2270 $config_options->{filesys
} = $fstypecb->get_active_text();
2271 &$set_sensitive_flag();
2278 my $get_float = sub {
2281 my $text = $entry->get_text();
2282 return undef if !defined($text);
2287 return undef if $text !~ m/^\d+(\.\d+)?$/;
2294 if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
2295 $config_options->{hdsize
} = $tmp;
2297 delete $config_options->{hdsize
};
2300 if (defined($tmp = &$get_float($entry_swapsize))) {
2301 $config_options->{swapsize
} = $tmp;
2303 delete $config_options->{swapsize
};
2306 if (defined($tmp = &$get_float($entry_maxroot))) {
2307 $config_options->{maxroot
} = $tmp;
2309 delete $config_options->{maxroot
};
2312 if (defined($tmp = &$get_float($entry_minfree))) {
2313 $config_options->{minfree
} = $tmp;
2315 delete $config_options->{minfree
};
2318 if (defined($tmp = &$get_float($entry_maxvz))) {
2319 $config_options->{maxvz
} = $tmp;
2321 delete $config_options->{maxvz
};
2327 sub get_zfs_raid_setup
{
2329 my $filesys = $config_options->{filesys
};
2331 my $dev_name_hash = {};
2334 my $bootdevlist = [];
2335 for (my $i = 0; $i < 8; $i++) {
2336 if (my $hd = $config_options->{"disksel$i"}) {
2337 my ($disk, $devname, $size, $model) = @$hd;
2338 die "device '$devname' is used more than once\n"
2339 if $dev_name_hash->{$devname};
2340 $dev_name_hash->{$devname} = $hd;
2341 push @$devlist, $hd;
2345 my $diskcount = scalar(@$devlist);
2346 die "$filesys need at least one device\n" if $diskcount < 1;
2349 if ($filesys eq 'zfs (RAID0)') {
2350 push @$bootdevlist, @$devlist[0];
2351 foreach my $hd (@$devlist) {
2354 } elsif ($filesys eq 'zfs (RAID1)') {
2355 die "zfs (RAID1) need at least 2 device\n" if $diskcount < 2;
2357 my $hd = @$devlist[0];
2358 my $expected_size = @$hd[2]; # all disks needs same size
2359 foreach $hd (@$devlist) {
2360 die "mirrored disks must have same size\n" if @$hd[2] != $expected_size;
2362 push @$bootdevlist, $hd;
2364 } elsif ($filesys eq 'zfs (RAID10)') {
2365 my $half = int($diskcount/2);
2366 die "zfs (RAID10) need at least 4 device\n" if $diskcount < 4;
2367 die "zfs (RAID10) need at an even numver of devices\n" if $half*2 != $diskcount;
2369 push @$bootdevlist, @$devlist[0], @$devlist[1];
2371 for (my $i = 0; $i < $diskcount; $i+=2) {
2372 my $hd1 = @$devlist[$i];
2373 my $hd2 = @$devlist[$i+1];
2374 die "mirrored disks must have same size\n" if @$hd1[2] != @$hd2[2];
2375 $cmd .= ' mirror ' . @$hd1[1] . ' ' . @$hd2[1];
2378 } elsif ($filesys =~ m/^zfs \(RAIDZ-([123])\)$/) {
2380 my $mindisks = 2 + $level;
2381 die "zfs (RAIDZ-$level) need at least $mindisks devices\n" if scalar(@$devlist) < $mindisks;
2382 my $hd = @$devlist[0];
2383 my $expected_size = @$hd[2]; # all disks needs same size
2384 $cmd .= " raidz$level";
2385 foreach $hd (@$devlist) {
2386 die "mirrored disks must have same size\n" if @$hd[2] != $expected_size;
2388 push @$bootdevlist, $hd;
2391 die "unknown zfs mode '$filesys'\n";
2394 return ($devlist, $bootdevlist, $cmd);
2397 sub create_hdsel_view
{
2401 my $vbox = Gtk3
::VBox-
>new (0, 0);
2402 $inbox->pack_start ($vbox, 1, 0, 0);
2403 my $hbox = Gtk3
::HBox-
>new (0, 0);
2404 $vbox->pack_start ($hbox, 0, 0, 10);
2406 my ($disk, $devname, $size, $model) = @{@$hds[0]};
2407 $target_hd = $devname;
2409 $target_hd_label = Gtk3
::Label-
>new ("Target Harddisk: ");
2410 $hbox->pack_start ($target_hd_label, 0, 0, 0);
2412 $target_hd_combo = Gtk3
::ComboBoxText-
>new();
2414 foreach my $hd (@$hds) {
2415 ($disk, $devname, $size, $model) = @$hd;
2416 $target_hd_combo->append_text (get_device_desc
($devname, $size, $model));
2419 $target_hd_combo->set_active (0);
2420 $target_hd_combo->signal_connect (changed
=> sub {
2421 $a = shift-
>get_active;
2422 my ($disk, $devname) = @{@$hds[$a]};
2423 $target_hd = $devname;
2426 $hbox->pack_start ($target_hd_combo, 0, 0, 10);
2428 my $options = Gtk3
::Button-
>new ('_Options');
2429 $options->signal_connect (clicked
=> \
&create_hdoption_view
);
2430 $hbox->pack_start ($options, 0, 0, 0);
2435 display_html
("page1.htm");
2437 set_next
(undef, sub {
2439 if ($config_options->{filesys
} =~ m/zfs/) {
2440 eval { get_zfs_raid_setup
(); };
2442 display_message
("Warning: $err\n" .
2443 "Please fix ZFS setup first.");
2445 create_country_view
();
2448 create_country_view
();
2453 sub create_extract_view
{
2457 display_html
("extract1-license.htm");
2458 $next->set_sensitive (0);
2460 my $vbox = Gtk3
::VBox-
>new (0, 0);
2461 $inbox->pack_start ($vbox, 1, 0, 0);
2462 my $hbox = Gtk3
::HBox-
>new (0, 0);
2463 $vbox->pack_start ($hbox, 0, 0, 10);
2465 my $vbox2 = Gtk3
::VBox-
>new (0, 0);
2466 $hbox->pack_start ($vbox2, 0, 0, 0);
2468 $progress_status = Gtk3
::Label-
>new ('');
2469 $vbox2->pack_start ($progress_status, 1, 1, 0);
2471 $progress = Gtk3
::ProgressBar-
>new;
2472 $progress->set_show_text(1);
2473 $progress->set_size_request (600, -1);
2475 $vbox2->pack_start ($progress, 0, 0, 0);
2479 my $tdir = $opt_testmode ?
"target" : "/target";
2481 my $base = $opt_testmode ?
"/pve/$release/install/pve-base.tar" : "/proxmox/pve-base.tar";
2483 eval { extract_data
($base, $tdir); };
2486 $next->set_sensitive (1);
2488 set_next
("_Reboot", sub { exit (0); } );
2491 display_html
("fail.htm");
2492 display_error
($err);
2495 display_html
("success.htm");
2499 sub create_intro_view
{
2503 display_html
("license.htm");
2505 set_next
("I a_gree", \
&create_hdsel_view
);
2508 $ipconf = get_ip_config
();
2510 $country = detect_country
() if $ipconf->{addr
} || $opt_testmode;;
2512 # read country, kmap and timezone infos
2513 $cmap = read_cmap
();
2515 create_main_window
();
2517 if (!defined ($hds) || (scalar (@$hds) <= 0)) {
2518 print "no hardisks found\n";
2519 display_html
("nohds.htm");
2520 set_next
("Reboot", sub { exit (0); } );
2523 foreach my $hd (@$hds) {
2524 my ($disk, $devname) = @$hd;
2525 next if $devname =~ m
|^/dev/md\d
+$|;
2526 print "found Disk$disk N:$devname\n";
2529 create_intro_view
();