]>
git.proxmox.com Git - pve-container.git/blob - src/PVE/LXCSetup.pm
197c224870972e66cea7014b727ada20ee4c56e1
7 use PVE
::LXCSetup
::Debian
;
8 use PVE
::LXCSetup
::Ubuntu
;
9 use PVE
::LXCSetup
::Redhat
;
12 debian
=> 'PVE::LXCSetup::Debian',
13 ubuntu
=> 'PVE::LXCSetup::Ubuntu',
14 redhat
=> 'PVE::LXCSetup::Redhat',
17 my $autodetect_type = sub {
20 my $lsb_fn = "$rootdir/etc/lsb-release";
22 my $data = PVE
::Tools
::file_get_contents
($lsb_fn);
23 if ($data =~ m/^DISTRIB_ID=Ubuntu$/im) {
26 } elsif (-f
"$rootdir/etc/debian_version") {
28 } elsif (-f
"$rootdir/etc/redhat-release") {
31 die "unable to detect OS disribution\n";
35 my ($class, $conf, $rootdir, $type) = @_;
37 die "no root directory\n" if !$rootdir || $rootdir eq '/';
39 my $self = bless { conf
=> $conf, $rootdir => $rootdir};
41 if (!defined($type)) {
42 # try to autodetect type
43 $type = &$autodetect_type($rootdir);
46 my $plugin_class = $plugins->{$type} ||
47 "no such OS type '$type'\n";
49 $self->{plugin
} = $plugin_class->new($conf, $rootdir);
57 $self->{plugin
}->template_fixup($self->{conf
});
63 $self->{plugin
}->setup_network($self->{conf
});
69 $self->{plugin
}->set_hostname($self->{conf
});
75 $self->{plugin
}->set_dns($self->{conf
});
81 $self->{plugin
}->setup_init($self->{conf
});
84 sub set_user_password
{
85 my ($self, $user, $pw) = @_;
87 $self->{plugin
}->set_user_password($self->{conf
}, $user, $pw);
93 $self->{plugin
}->pre_start_hook($self->{conf
});
96 sub post_create_hook
{
97 my ($self, $root_password) = @_;
99 $self->{plugin
}->post_create_hook($self->{conf
}, $root_password);