]> git.proxmox.com Git - pve-container.git/blame - src/pve-container-stop-wrapper
setup: fix using non-plugin methods
[pve-container.git] / src / pve-container-stop-wrapper
CommitLineData
395139e2
FG
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6# sanity checks
7my $vmid = $ARGV[0] or exit(1);
8exit(0) if $vmid !~ /^\d+$/;
9exit(0) if !-e "/etc/pve/lxc/${vmid}.conf";
10
11if (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}