]>
git.proxmox.com Git - pve-container.git/blob - src/PVE/LXC/Setup/Alpine.pm
1 package PVE
::LXC
::Setup
::Alpine
;
10 use PVE
::LXC
::Setup
::Base
;
11 use PVE
::LXC
::Setup
::Debian
;
13 use base
qw(PVE::LXC::Setup::Base);
16 my ($class, $conf, $rootdir) = @_;
18 my $version = PVE
::Tools
::file_read_firstline
("$rootdir/etc/alpine-release");
20 my $self = { conf
=> $conf, rootdir
=> $rootdir, version
=> $version };
21 $conf->{ostype
} = "alpine";
22 return bless $self, $class;
25 # Alpine doesn't support the /dev/lxc/ subdirectory.
31 my ($self, $conf) = @_;
33 # enable networking service
34 $self->ct_symlink('/etc/init.d/networking',
35 '/etc/runlevels/boot/networking');
37 $self->ct_symlink('/etc/init.d/bootmisc',
38 '/etc/runlevels/boot/bootmisc');
39 $self->ct_symlink('/etc/init.d/hostname',
40 '/etc/runlevels/boot/hostname');
42 $self->ct_symlink('/etc/init.d/killprocs',
43 '/etc/runlevels/shutdown/killprocs');
44 $self->ct_symlink('/etc/init.d/savecache',
45 '/etc/runlevels/shutdown/savecache');
47 $self->setup_securetty($conf);
51 my ($self, $conf) = @_;
53 my $filename = "/etc/inittab";
54 return if !$self->ct_file_exists($filename);
56 my $ttycount = PVE
::LXC
::Config-
>get_tty_count($conf);
57 my $inittab = $self->ct_file_get_contents($filename);
61 !/^\s*tty\d+:\d*:[^:]*:.*getty/
62 } split(/\n/, $inittab);
64 $inittab = join("\n", @lines) . "\n";
66 for (my $id = 1; $id <= $ttycount; $id++) {
67 next if $id == 7; # reserved for X11
68 $inittab .= "tty$id\::respawn:/sbin/getty 38400 tty$id\n";
71 $self->ct_file_set_contents($filename, $inittab);
75 # Network is debian compatible, but busybox' udhcpc6 is unfinished
76 my ($self, $conf) = @_;
78 # XXX: udhcpc6 in busybox is broken; once a working alpine release comes
79 # we can remove this bit.
81 # Filter out ipv6 dhcp and turn it into 'manual' so they see what's up.
83 # XXX: slaac works different from debian - busybox has no 'auto'
84 # configuration type - https://wiki.alpinelinux.org/wiki/Configure_Networking#IPv6_Stateless_Autoconfiguration
85 # the suggested configuration sadly does not take the interface up, but
86 # at least with the workaround the networking starts and if an ipv4 is
87 # configured slaac for ipv6 works (unless accept_ra = 0 in the node)
91 foreach my $k (keys %$conf) {
92 my $value = $conf->{$k};
93 $newconf->{$k} = $value;
94 next if $k !~ m/^net(\d+)$/;
96 my $netstring = $value;
98 my $d = PVE
::LXC
::Config-
>parse_lxc_network($netstring);
99 if (defined($d->{ip6
}) && ($d->{ip6
} eq 'dhcp' || $d->{ip6
} eq 'auto')) {
100 $d->{ip6
} = 'manual';
101 $netstring = PVE
::LXC
::Config-
>print_lxc_network($d);
103 $newconf->{$k} = $netstring;
106 PVE
::LXC
::Setup
::Debian
::setup_network
($self, $newconf);