]> git.proxmox.com Git - pve-container.git/blob - src/pve-container-stop-wrapper
fix #1874: autodev hook: setup devices cgroup
[pve-container.git] / src / pve-container-stop-wrapper
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 # sanity checks
7 my $vmid = $ARGV[0] or exit(1);
8 exit(0) if $vmid !~ /^\d+$/;
9 exit(0) if !-e "/etc/pve/lxc/${vmid}.conf";
10
11 if (unlink("/var/lib/lxc/$vmid/reboot")) {
12 # restart if rebooted from within container
13 exec {'systemctl'} 'systemctl', '--no-block', 'restart', "pve-container\@${vmid}.service";
14 } elsif (!defined($ENV{EXIT_CODE}) || $ENV{EXIT_CODE} ne "exited") {
15 # stop if called via "systemctl stop lxc@ID"
16 exec {'lxc-stop'} 'lxc-stop', '-n', $vmid;
17 } else {
18 # just exit if container was shutdown from within or via lxc-stop
19 exit(0);
20 }