]> git.proxmox.com Git - pve-container.git/blame - src/PVE/LXCSetup.pm
autodetect OS distribution
[pve-container.git] / src / PVE / LXCSetup.pm
CommitLineData
1c7f4f65
DM
1package PVE::LXCSetup;
2
3use strict;
4use warnings;
5
6use PVE::LXCSetup::Debian;
7
8my $plugins = {
9 debian => 'PVE::LXCSetup::Debian',
10};
11
bdd4194c
DM
12my $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 23sub 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
39sub setup_network {
40
41
42}
43
44sub set_hostname {
45 my ($self) = @_;
46
47 $self->{plugin}->set_hostname($self->{conf});
48}
49
50sub set_user_passwort {
51
52}
53
54sub post_create {
55 my ($self) = @_;
56
57 $self->{plugin}->post_create($self->{conf});
58}
59
601;