]>
git.proxmox.com Git - pve-container.git/blob - src/PVE/LXC/Setup.pm
1 package PVE
::LXC
::Setup
;
7 use PVE
::LXC
::Setup
::Debian
;
8 use PVE
::LXC
::Setup
::Ubuntu
;
9 use PVE
::LXC
::Setup
::Redhat
;
10 use PVE
::LXC
::Setup
::ArchLinux
;
13 debian
=> 'PVE::LXC::Setup::Debian',
14 ubuntu
=> 'PVE::LXC::Setup::Ubuntu',
15 redhat
=> 'PVE::LXC::Setup::Redhat',
16 archlinux
=> 'PVE::LXC::Setup::ArchLinux',
19 my $autodetect_type = sub {
22 my $lsb_fn = "$rootdir/etc/lsb-release";
24 my $data = PVE
::Tools
::file_get_contents
($lsb_fn);
25 if ($data =~ m/^DISTRIB_ID=Ubuntu$/im) {
28 } elsif (-f
"$rootdir/etc/debian_version") {
30 } elsif (-f
"$rootdir/etc/redhat-release") {
32 } elsif (-f
"$rootdir/etc/arch-release") {
35 die "unable to detect OS disribution\n";
39 my ($class, $conf, $rootdir, $type) = @_;
41 die "no root directory\n" if !$rootdir || $rootdir eq '/';
43 my $self = bless { conf
=> $conf, $rootdir => $rootdir};
45 if (!defined($type)) {
46 # try to autodetect type
47 $type = &$autodetect_type($rootdir);
50 my $plugin_class = $plugins->{$type} ||
51 "no such OS type '$type'\n";
53 $self->{plugin
} = $plugin_class->new($conf, $rootdir);
61 $self->{plugin
}->template_fixup($self->{conf
});
67 $self->{plugin
}->setup_network($self->{conf
});
73 $self->{plugin
}->set_hostname($self->{conf
});
79 $self->{plugin
}->set_dns($self->{conf
});
85 $self->{plugin
}->setup_init($self->{conf
});
88 sub set_user_password
{
89 my ($self, $user, $pw) = @_;
91 $self->{plugin
}->set_user_password($self->{conf
}, $user, $pw);
94 sub rewrite_ssh_host_keys
{
97 $self->{plugin
}->rewrite_ssh_host_keys($self->{conf
});
103 $self->{plugin
}->pre_start_hook($self->{conf
});
106 sub post_create_hook
{
107 my ($self, $root_password) = @_;
109 $self->{plugin
}->post_create_hook($self->{conf
}, $root_password);