]>
git.proxmox.com Git - pve-container.git/blob - src/lxc-pve-poststop-hook
12 use PVE
:: RPCEnvironment
;
13 use PVE
:: JSONSchema
qw(get_standard_option) ;
16 use PVE
:: Storage
:: Plugin
;
20 use base
qw(PVE::CLIHandler) ;
22 $ENV { 'PATH' } = '/sbin:/bin:/usr/sbin:/usr/bin' ;
24 initlog
( 'lxc-pve-poststop-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-poststop-hook' ,
41 path
=> 'lxc-pve-poststop-hook' ,
43 description
=> "vm_stop_cleanup." ,
45 additionalProperties
=> 0 ,
48 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)." ,
55 returns
=> { type
=> 'null' },
60 return undef if $param ->{ name
} !~ m/^\d+$/ ;
62 my $vmid = $param ->{ name
};
64 return undef if ! - f PVE
:: LXC
:: config_file
( $vmid );
66 my $conf = PVE
:: LXC
:: load_config
( $vmid );
68 my $storage_cfg = PVE
:: Storage
:: config
();
70 PVE
:: LXC
:: vm_stop_cleanup
( $storage_cfg, $vmid, $conf );
76 push @ARGV, 'help' if ! scalar ( @ARGV );
80 if (( scalar ( @ARGV ) == 1 ) && ( $ARGV [ 0 ] eq 'printmanpod' ) ||
81 ( $ARGV [ 0 ] eq 'verifyapi' )) {
83 } elsif (( scalar ( @ARGV ) == 3 ) && ( $ARGV [ 1 ] eq 'lxc' ) && ( $ARGV [ 2 ] eq 'post-stop' )) {
84 $param ->{ name
} = $ENV { 'LXC_NAME' };
85 die "got wrong name" if $param ->{ name
} ne $ARGV [ 0 ];
92 my $cmddef = [ __PACKAGE__
, 'lxc-pve-poststop-hook' , [], $param ];
94 PVE
:: CLIHandler
:: handle_simple_cmd
( $cmddef, \
@ARGV, undef , $0 );
102 lxc-pve - LXC post stop hook for Proxmox VE
110 This post stop hook detach loop devices and deactivate volumes for pve container.
116 =include pve_copyright