]>
git.proxmox.com Git - pve-container.git/blob - src/lxc-pve-mount-hook
cc7c98b5abe47f8c32fa4ae08fdbad4b5cfd30ba
12 use PVE
::RPCEnvironment
;
13 use PVE
::JSONSchema
qw(get_standard_option);
20 use base
qw(PVE::CLIHandler);
22 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
24 initlog
('lxc-pve-mount-hook');
26 die "please run as root\n" if $> != 0;
28 PVE
::INotify
::inotify_init
();
30 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
31 $rpcenv->set_language($ENV{LANG
});
32 $rpcenv->set_user('root@pam');
34 # we cannot use cfs_read here (permission problem)
35 #$rpcenv->init_request();
37 my $nodename = PVE
::INotify
::nodename
();
39 __PACKAGE__-
>register_method ({
40 name
=> 'lxc-pve-mount-hook',
41 path
=> 'lxc-pve-mount-hook',
43 description
=> "Create a new container root directory.",
45 additionalProperties
=> 0,
47 name
=> get_standard_option
('pve-vmid'),
49 description
=> "The path to the container configuration directory (LXC internal argument - do not pass manually!).",
53 description
=> "The path to the container's rootfs (LXC internal argument - do not pass manually!)",
58 returns
=> { type
=> 'null' },
63 my $private = $param->{rootfs
};
65 die "got strange path '$param->{path}'\n"
66 if $param->{path
} !~ m!^/etc/pve/lxc/$param->{name}/config$!;
68 my $raw = PVE
::Tools
::file_get_contents
($param->{path
});
69 my $conf = PVE
::LXC
::parse_lxc_config
($param->{path
}, $raw);
71 my $lxc_setup = PVE
::LXCSetup-
>new($conf);
72 $lxc_setup->pre_start_hook();
78 push @ARGV, 'help' if !scalar(@ARGV);
82 if ((scalar(@ARGV) == 1) && ($ARGV[0] eq 'printmanpod') ||
83 ($ARGV[0] eq 'verifyapi')) {
85 } elsif ((scalar(@ARGV) == 3) && ($ARGV[1] eq 'lxc') && ($ARGV[2] eq 'mount')) {
86 $param->{name
} = $ENV{'LXC_NAME'};
87 die "got wrong name" if $param->{name
} ne $ARGV[0];
89 $param->{path
} = $ENV{'LXC_CONFIG_FILE'};
90 $param->{rootfs
} = $ENV{'LXC_ROOTFS_PATH'};
96 my $cmddef = [ __PACKAGE__
, 'lxc-pve-mount-hook', [], $param];
98 PVE
::CLIHandler
::handle_simple_cmd
($cmddef, \
@ARGV, undef, $0);
106 lxc-pve - LXC mount hook for Proxmox VE
114 This mount hook sets the network and hostname for the container.
120 =include pve_copyright