Merge pull request #17484 from srp/nixos-container-terminate
nixos-container: add 'terminate' command which 'destroy' now uses
This commit is contained in:
commit
dece583a94
@ -23,7 +23,7 @@ Usage: nixos-container list
|
||||
nixos-container destroy <container-name>
|
||||
nixos-container start <container-name>
|
||||
nixos-container stop <container-name>
|
||||
nixos-container kill <container-name> [--signal <signal-specifier>]
|
||||
nixos-container terminate <container-name>
|
||||
nixos-container status <container-name>
|
||||
nixos-container update <container-name> [--config <string>] [--config-file <path>]
|
||||
nixos-container login <container-name>
|
||||
@ -210,12 +210,9 @@ sub isContainerRunning {
|
||||
return $status =~ /ActiveState=active/;
|
||||
}
|
||||
|
||||
sub killContainer {
|
||||
my @args = ();
|
||||
push(@args, ("--signal", $signal)) if ($signal ne "");
|
||||
|
||||
system("machinectl", "kill", $containerName, @args) == 0
|
||||
or die "$0: failed to kill container\n";
|
||||
sub terminateContainer {
|
||||
system("machinectl", "terminate", $containerName) == 0
|
||||
or die "$0: failed to terminate container\n";
|
||||
}
|
||||
|
||||
sub stopContainer {
|
||||
@ -260,8 +257,7 @@ if ($action eq "destroy") {
|
||||
die "$0: cannot destroy declarative container (remove it from your configuration.nix instead)\n"
|
||||
unless POSIX::access($confFile, &POSIX::W_OK);
|
||||
|
||||
$signal = "SIGKILL";
|
||||
killContainer if (isContainerRunning);
|
||||
terminateContainer if (isContainerRunning);
|
||||
|
||||
safeRemoveTree($profileDir) if -e $profileDir;
|
||||
safeRemoveTree($gcRootsDir) if -e $gcRootsDir;
|
||||
@ -278,8 +274,8 @@ elsif ($action eq "stop") {
|
||||
stopContainer;
|
||||
}
|
||||
|
||||
elsif ($action eq "kill") {
|
||||
killContainer;
|
||||
elsif ($action eq "terminate") {
|
||||
terminateContainer;
|
||||
}
|
||||
|
||||
elsif ($action eq "status") {
|
||||
|
Loading…
Reference in New Issue
Block a user