]>
Commit | Line | Data |
---|---|---|
b0143ab1 WB |
1 | package PVE::LXC::Setup::Fedora; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
81a6ec3f | 6 | use PVE::LXC::Setup::CentOS; |
b0143ab1 | 7 | |
81a6ec3f | 8 | use base qw(PVE::LXC::Setup::CentOS); |
b0143ab1 WB |
9 | |
10 | sub new { | |
d721cb54 | 11 | my ($class, $conf, $rootdir, $os_release) = @_; |
b0143ab1 | 12 | |
d721cb54 | 13 | my $version = $os_release->{VERSION_ID}; |
5805ea4f | 14 | die "unsupported Fedora release '$version'\n" if !($version >= 22 && $version <= 38); |
b0143ab1 WB |
15 | |
16 | my $self = { conf => $conf, rootdir => $rootdir, version => $version }; | |
17 | ||
18 | $conf->{ostype} = "fedora"; | |
19 | ||
20 | return bless $self, $class; | |
21 | } | |
22 | ||
97e3e8e8 WB |
23 | sub template_fixup { |
24 | my ($self, $conf) = @_; | |
25 | $self->setup_securetty($conf); | |
26 | $self->ct_unlink('/etc/systemd/system/getty@.service'); | |
27 | } | |
28 | ||
29 | sub setup_init { | |
30 | my ($self, $conf) = @_; | |
31 | $self->setup_container_getty_service($conf); | |
e652eaf8 WB |
32 | |
33 | my $version = $self->{version}; | |
34 | ||
35 | if ($version >= 37) { | |
36 | # systemd-networkd is disabled by the preset in >=37, reenable it | |
37 | # this only affects the first-boot (if no /etc/machien-id exists). | |
38 | $self->ct_mkdir('/etc/systemd/system-preset', 0755); | |
39 | $self->ct_file_set_contents( | |
40 | '/etc/systemd/system-preset/00-pve.preset', | |
41 | "enable systemd-networkd.service\n", | |
42 | ); | |
43 | } | |
97e3e8e8 WB |
44 | } |
45 | ||
6751d98a SI |
46 | sub setup_network { |
47 | my ($self, $conf) = @_; | |
48 | ||
49 | # systemd-networkd is default in fedora-templates from upstream since | |
50 | # 25, however quite a few workarounds were posted in the forum, recommending | |
51 | # to start the (legacy) network.service via /etc/rc.local for fedora > 25. | |
52 | # /etc/sysconfig/network is not present in the templates for fedora > 25. | |
53 | # use its presence to decide, whether to configure the legacy config | |
54 | # additionally for 25, 26, 27. | |
55 | ||
56 | my $sysconfig_used = $self->ct_file_exists("/etc/sysconfig/network"); | |
57 | ||
58 | my $version = $self->{version}; | |
59 | ||
dd9b8264 TL |
60 | my $setup_sysconfig = ($version <= 24 || ($version <= 27 && $sysconfig_used)); |
61 | my $setup_systemd = ($version >= 25); | |
6751d98a SI |
62 | |
63 | $self->SUPER::setup_network($conf) if $setup_sysconfig; | |
64 | $self->SUPER::setup_systemd_networkd($conf) if $setup_systemd; | |
65 | } | |
b0143ab1 | 66 | 1; |