+++ /dev/null
-#!/usr/bin/perl
-
-
-# NOTE: we do not use this at all
-
-use strict;
-use warnings;
-use POSIX;
-use File::Path;
-
-use PVE::SafeSyslog;
-use PVE::Tools;
-use PVE::Cluster;
-use PVE::INotify;
-use PVE::RPCEnvironment;
-use PVE::JSONSchema qw(get_standard_option);
-use PVE::CLIHandler;
-use PVE::Storage;
-use PVE::LXC;
-use PVE::LXCSetup;
-use Data::Dumper;
-
-use base qw(PVE::CLIHandler);
-
-$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
-
-initlog ('lxc-pve');
-
-die "please run as root\n" if $> != 0;
-
-
-PVE::INotify::inotify_init();
-
-my $rpcenv = PVE::RPCEnvironment->init('cli');
-$rpcenv->set_language($ENV{LANG});
-$rpcenv->set_user('root@pam');
-
-my $nodename = PVE::INotify::nodename();
-
-__PACKAGE__->register_method ({
- name => 'lxc-pve',
- path => 'lxc-pve',
- method => 'GET',
- description => "Create a new container root directory.",
- parameters => {
- additionalProperties => 0,
- properties => {
- name => get_standard_option('pve-vmid'),
- path => {
- description => "The path to the container configuration directory (LXC internal argument - do not pass manually!).",
- type => 'string',
- },
- rootfs => {
- description => "The path to the container's rootfs (LXC internal argument - do not pass manually!)",
- type => 'string',
- },
- archive => {
- description => "Path to the template tar file.",
- type => 'string',
- },
- password => {
- optional => 1,
- type => 'string',
- description => "Sets root password inside container.",
- },
- 'mapped-uid' => {
- description => " A uid map (user namespaces - LXC internal argument - do not pass manually!)",
- type => 'string',
- optional => 1,
- },
- 'mapped-gid' => {
- description => " A gid map (user namespaces - LXC internal argument - do not pass manually!)",
- type => 'string',
- optional => 1,
- },
- },
- },
- returns => { type => 'null' },
-
- code => sub {
- my ($param) = @_;
-
- # set UID and GUI, because only original user can access /etc/pve
- $< = $param->{'mapped-uid'} if defined($param->{'mapped-uid'});
- $( = $param->{'mapped-gid'} if defined($param->{'mapped-gid'});
-
- my $userns = defined($param->{'mapped-uid'}) ? 1 : 0;
-
- my $private = $param->{rootfs};
-
- die "got strange path '$param->{path}'\n"
- if $param->{path} !~ m!^/etc/pve/lxc/$param->{name}/?$!;
-
- # print "TEST $< $(\n";
-
- $rpcenv->init_request();
-
- my $conf = PVE::LXC::load_config($param->{name});
- # print Dumper($conf);
-
- #$< = $( = 0; # switch back to container root
- #print "TEST $< $(\n";
-
- my $cmd = ['tar', 'xpf', $param->{archive}, '--numeric-owner', '--totals',
- '--sparse', '-C', $private];
- push @$cmd, '--anchored';
- push @$cmd, '--exclude' , '/dev/*';
-# push @$cmd, '--exclude' , '/dev/loop*';
-# push @$cmd, '--exclude' , '/dev/ram*';
-# push @$cmd, '--exclude' , '/dev/pty*';
-# push @$cmd, '--exclude' , '/dev/tty*';
-# push @$cmd, '--exclude' , '/dev/pty*';
-# push @$cmd, '--exclude' , '/dev/null';
-# push @$cmd, '--exclude' , '/dev/random';
-# push @$cmd, '--exclude' , '/dev/urandom';
-# push @$cmd, '--exclude' , '/dev/console';
-# push @$cmd, '--exclude' , '/dev/zero';
-# push @$cmd, '--exclude' , '/dev/ptmx';
-# push @$cmd, '--exclude' , '/dev/port';
-# push @$cmd, '--exclude' , '/dev/mem';
-# push @$cmd, '--exclude' , '/dev/kmem';
-# push @$cmd, '--exclude' , '/dev/full';
-
- print "extracting archive '$param->{archive}' to '$private'\n";
- PVE::Tools::run_command($cmd);
-
- File::Path::make_path("$private/dev/pts");
-
- # template/OS specific configuration
- $conf->{'lxc.arch'} = 'i386'; # || x86_64
-
- $conf->{'lxc.include'} = "/usr/share/lxc/config/debian.common.conf";
- $conf->{'lxc.hook.mount'} = "/usr/share/lxc/hooks/lxc-pve-mount-hook";
-
- if ($userns) {
- die "also include me";
- $conf->{'lxc.include'} = "/usr/share/lxc/config/debian.userns.conf";
- }
-
- PVE::LXC::write_config($param->{name}, $conf);
-
- # fixme: use correct dist
- my $lxc_setup = PVE::LXCSetup->new($conf);
- $lxc_setup->post_create_hook($param->{password});
-
- return undef;
- }});
-
-my $cmddef = [ __PACKAGE__, 'lxc-pve' ];
-
-push @ARGV, 'help' if !scalar(@ARGV);
-
-PVE::CLIHandler::handle_simple_cmd($cmddef, \@ARGV, undef, $0);
-
-exit 0;
-
-__END__
-
-=head1 NAME
-
-lxc-pve - create containers from Proxmox VE templates
-
-=head1 SYNOPSIS
-
-=include synopsis
-
-=head1 DESCRIPTION
-
-This script creates containers from Proxmox VE templates. This is always
-called from within lxc-create, so please do not try to use this directly.
-Use 'lct' instead.
-
-=head1 SEE ALSO
-
-lct(1)
-
-=include pve_copyright