]>
git.proxmox.com Git - pve-container.git/blob - src/lxc-pve-poststop-hook
6 exit 0 if $ENV { LXC_NAME
} && $ENV { LXC_NAME
} !~ /^\d+$/ ;
15 use PVE
:: RPCEnvironment
;
16 use PVE
:: JSONSchema
qw(get_standard_option) ;
19 use PVE
:: Storage
:: Plugin
;
23 use base
qw(PVE::CLIHandler) ;
25 $ENV { 'PATH' } = '/sbin:/bin:/usr/sbin:/usr/bin' ;
27 initlog
( 'lxc-pve-poststop-hook' );
29 die "please run as root \n " if $> != 0 ;
31 PVE
:: INotify
:: inotify_init
();
33 my $rpcenv = PVE
:: RPCEnvironment-
> init ( 'cli' );
34 $rpcenv -> set_language ( $ENV { LANG
});
35 $rpcenv -> set_user ( 'root @pam ' );
37 # we cannot use cfs_read here (permission problem)
38 #$rpcenv->init_request();
40 my $nodename = PVE
:: INotify
:: nodename
();
42 __PACKAGE__-
> register_method ({
43 name
=> 'lxc-pve-poststop-hook' ,
44 path
=> 'lxc-pve-poststop-hook' ,
46 description
=> "vm_stop_cleanup." ,
48 additionalProperties
=> 0 ,
51 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)." ,
58 returns
=> { type
=> 'null' },
63 return undef if $param ->{ name
} !~ m/^\d+$/ ;
65 my $vmid = $param ->{ name
};
67 return undef if ! - f PVE
:: LXC
:: config_file
( $vmid );
69 my $conf = PVE
:: LXC
:: load_config
( $vmid );
71 my $storage_cfg = PVE
:: Storage
:: config
();
73 PVE
:: LXC
:: vm_stop_cleanup
( $storage_cfg, $vmid, $conf );
79 push @ARGV, 'help' if ! scalar ( @ARGV );
83 if (( scalar ( @ARGV ) == 1 ) && ( $ARGV [ 0 ] eq 'printmanpod' ) ||
84 ( $ARGV [ 0 ] eq 'verifyapi' )) {
86 } elsif (( scalar ( @ARGV ) == 3 ) && ( $ARGV [ 1 ] eq 'lxc' ) && ( $ARGV [ 2 ] eq 'post-stop' )) {
87 $param ->{ name
} = $ENV { 'LXC_NAME' };
88 die "got wrong name" if $param ->{ name
} ne $ARGV [ 0 ];
95 my $cmddef = [ __PACKAGE__
, 'lxc-pve-poststop-hook' , [], $param ];
97 PVE
:: CLIHandler
:: handle_simple_cmd
( $cmddef, \
@ARGV, undef , $0 );
105 lxc-pve - LXC post stop hook for Proxmox VE
113 This post stop hook detach loop devices and deactivate volumes for pve container.
119 =include pve_copyright