]> git.proxmox.com Git - pve-container.git/blob - src/PVE/LXC/Setup/Alpine.pm
install Alpine.pm and configure its network
[pve-container.git] / src / PVE / LXC / Setup / Alpine.pm
1 package PVE::LXC::Setup::Alpine;
2
3 use strict;
4 use warnings;
5
6 use PVE::LXC;
7 use PVE::Network;
8 use File::Path;
9
10 use PVE::LXC::Setup::Base;
11 use PVE::LXC::Setup::Debian;
12
13 use base qw(PVE::LXC::Setup::Base);
14
15 sub new {
16 my ($class, $conf, $rootdir) = @_;
17 my $self = { conf => $conf, rootdir => $rootdir, version => 0 };
18 $conf->{ostype} = "alpine";
19 return bless $self, $class;
20 }
21
22 sub template_fixup {
23 my ($self, $conf) = @_;
24 my $rootdir = $self->{rootdir};
25 # enable networking service
26 $self->ct_symlink('/etc/init.d/networking',
27 '/etc/runlevels/boot/networking');
28 # fixup any symlinks
29 $self->ct_symlink('/etc/init.d/bootmisc',
30 '/etc/runlevels/boot/bootmisc');
31 $self->ct_symlink('/etc/init.d/hostname',
32 '/etc/runlevels/boot/hostname');
33 # fix stop system
34 $self->ct_symlink('/etc/init.d/killprocs',
35 '/etc/runlevels/shutdown/killprocs');
36 $self->ct_symlink('/etc/init.d/savecache',
37 '/etc/runlevels/shutdown/savecache');
38 }
39
40 sub setup_init {
41 # Nothing to do
42 }
43
44 sub setup_network {
45 # Network is debian compatible, but busybox' udhcpc6 is unfinished
46 my ($self, $conf) = @_;
47
48 # XXX: udhcpc6 in busybox is broken; once a working alpine release comes
49 # we can remove this bit.
50 #
51 # Filter out ipv6 dhcp and turn it into 'manual' so they see what's up.
52 my $netconf = {};
53 my $networks = {};
54 foreach my $k (keys %$conf) {
55 next if $k !~ m/^net(\d+)$/;
56 my $netstring = $conf->{$k};
57 # check for dhcp6:
58 my $d = PVE::LXC::parse_lxc_network($netstring);
59 if (defined($d->{ip6}) && $d->{ip6} eq 'dhcp') {
60 $d->{ip6} = 'manual';
61 $netstring = PVE::LXC::print_lxc_network($d);
62 }
63 $netconf->{$k} = $netstring;
64 }
65
66 PVE::LXC::Setup::Debian::setup_network($self, $netconf);
67 }
68
69 1;