]>
Commit | Line | Data |
---|---|---|
c2f72dd6 TL |
1 | package ProxmoxInstallerSetup; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | my $product_cfg = { | |
7 | pve => { | |
8 | fullname => 'Proxmox VE', | |
9 | port => '8006', | |
60db5953 | 10 | enable_btrfs => 1, |
c2f72dd6 TL |
11 | bridged_network => 1, |
12 | }, | |
13 | pmg => { | |
14 | fullname => 'Proxmox Mail Gateway', | |
15 | port => '8006', | |
16 | enable_btrfs => 0, | |
17 | bridged_network => 0, | |
18 | }, | |
19 | pbs => { | |
20 | fullname => 'Proxmox Backup Server', | |
21 | port => '8007', | |
22 | enable_btrfs => 0, | |
23 | bridged_network => 0, | |
24 | }, | |
25 | }; | |
26 | ||
27 | sub setup { | |
28 | my $cd_info = get_cd_info(); | |
29 | my $product = $cd_info->{product}; | |
30 | ||
31 | my $setup_info = $product_cfg->{$product}; | |
32 | die "unknown product '$product'\n" if !$setup_info; | |
33 | ||
34 | $setup_info->{product} = $product; | |
35 | ||
36 | return ($setup_info, $cd_info); | |
37 | } | |
38 | ||
39 | sub get_cd_info { | |
40 | my $info_fn = '/.cd-info'; # default place in the ISO environment | |
41 | if (!-f $info_fn && -f "cd-info.test") { | |
42 | $info_fn = "cd-info.test"; # use from CWD for test mode | |
43 | } | |
44 | ||
45 | open(my $fh, '<', $info_fn) or die "Could not open CD info file '$info_fn' $!"; | |
46 | ||
47 | my $cd_info = {}; | |
48 | while (my $line = <$fh>) { | |
49 | chomp $line; | |
50 | if ($line =~ /^(\S+)=['"]?(.+?)['"]?$/) { # we control cd-info content, so good enough. | |
51 | $cd_info->{lc($1)} = $2; | |
52 | } | |
53 | } | |
54 | close ($fh); | |
55 | ||
56 | die "CD-info is missing required key 'product'!\n" if !defined $cd_info->{product}; | |
57 | ||
58 | return $cd_info; | |
59 | } | |
60 | ||
61 | 1; |