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