]>
git.proxmox.com Git - pve-container.git/blob - src/lxc-pve-prestart-hook
3 package lxc_pve_prestart_hook
;
8 exit 0 if $ENV { LXC_NAME
} && $ENV { LXC_NAME
} !~ /^\d+$/ ;
17 use PVE
:: RPCEnvironment
;
18 use PVE
:: JSONSchema
qw(get_standard_option) ;
24 use base
qw(PVE::CLIHandler) ;
26 __PACKAGE__-
> register_method ({
27 name
=> 'lxc-pve-prestart-hook' ,
28 path
=> 'lxc-pve-prestart-hook' ,
30 description
=> "Create a new container root directory." ,
32 additionalProperties
=> 0 ,
35 description
=> "The container name. This hook is only active for containers using numeric IDs, where configuration is stored on /etc/pve/lxc/<name>.conf (else it is just a NOP)." ,
41 description
=> "The path to the container configuration directory (LXC internal argument - do not pass manually!)." ,
45 description
=> "The path to the container's rootfs (LXC internal argument - do not pass manually!)" ,
50 returns
=> { type
=> 'null' },
55 return undef if $param ->{ name
} !~ m/^\d+$/ ;
57 my $rootdir = $ENV { LXC_ROOTFS_MOUNT
};
59 my $vmid = $param ->{ name
};
61 PVE
:: Cluster
:: check_cfs_quorum
(); # only start if we have quorum
63 return undef if ! - f PVE
:: LXC
:: config_file
( $vmid );
65 my $conf = PVE
:: LXC
:: load_config
( $vmid );
67 my $storage_cfg = PVE
:: Storage
:: config
();
69 my $vollist = PVE
:: LXC
:: get_vm_volumes
( $conf );
70 my $loopdevlist = PVE
:: LXC
:: get_vm_volumes
( $conf, 'rootfs' );
72 PVE
:: Storage
:: activate_volumes
( $storage_cfg, $vollist );
77 push @ARGV, 'help' if ! scalar ( @ARGV );
81 if (( scalar ( @ARGV ) == 3 ) && ( $ARGV [ 1 ] eq 'lxc' ) && ( $ARGV [ 2 ] eq 'pre-start' )) {
82 $param ->{ name
} = $ENV { 'LXC_NAME' };
83 die "got wrong name" if $param ->{ name
} ne $ARGV [ 0 ];
85 $param ->{ path
} = $ENV { 'LXC_CONFIG_FILE' };
86 $param ->{ rootfs
} = $ENV { 'LXC_ROOTFS_PATH' };
92 our $cmddef = [ __PACKAGE__
, 'lxc-pve-prestart-hook' , [], $param ];
94 __PACKAGE__-
> run_cli_handler ();