]>
Commit | Line | Data |
---|---|---|
1c7f4f65 DM |
1 | package PVE::LXCSetup; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use PVE::LXCSetup::Debian; | |
7 | ||
8 | my $plugins = { | |
9 | debian => 'PVE::LXCSetup::Debian', | |
10 | }; | |
11 | ||
bdd4194c DM |
12 | my $autodetect_type = sub { |
13 | my ($conf) = @_; | |
14 | ||
15 | my $rootfs = $conf->{'lxc.rootfs'}; | |
16 | if (-f "$rootfs/etc/debian_version") { | |
17 | ||
18 | return "debian"; | |
19 | } | |
20 | die "unable to detect OS disribution\n"; | |
21 | }; | |
22 | ||
1c7f4f65 | 23 | sub new { |
bdd4194c | 24 | my ($class, $conf, $type) = @_; |
1c7f4f65 DM |
25 | |
26 | my $self = bless { conf => $conf }; | |
27 | ||
bdd4194c DM |
28 | if (!defined($type)) { |
29 | # try to autodetect type | |
30 | $type = &$autodetect_type($conf); | |
31 | } | |
32 | ||
1c7f4f65 DM |
33 | $self->{plugin} = $plugins->{$type} || |
34 | "no such OS type '$type'\n"; | |
35 | ||
36 | return $self; | |
37 | } | |
38 | ||
39 | sub setup_network { | |
40 | ||
41 | ||
42 | } | |
43 | ||
44 | sub set_hostname { | |
45 | my ($self) = @_; | |
46 | ||
47 | $self->{plugin}->set_hostname($self->{conf}); | |
48 | } | |
49 | ||
50 | sub set_user_passwort { | |
51 | ||
52 | } | |
53 | ||
54 | sub post_create { | |
55 | my ($self) = @_; | |
56 | ||
57 | $self->{plugin}->post_create($self->{conf}); | |
58 | } | |
59 | ||
60 | 1; |