nixos-container: Add status command

This commit is contained in:
Eelco Dolstra 2014-08-18 13:46:54 +02:00
parent ab7b973b33
commit e7860f04c2

View File

@ -21,6 +21,7 @@ Usage: nixos-container list
nixos-container destroy <container-name> nixos-container destroy <container-name>
nixos-container start <container-name> nixos-container start <container-name>
nixos-container stop <container-name> nixos-container stop <container-name>
nixos-container status <container-name>
nixos-container login <container-name> nixos-container login <container-name>
nixos-container root-login <container-name> nixos-container root-login <container-name>
nixos-container run <container-name> -- args... nixos-container run <container-name> -- args...
@ -155,7 +156,11 @@ my $profileDir = "/nix/var/nix/profiles/per-container/$containerName";
my $gcRootsDir = "/nix/var/nix/gcroots/per-container/$containerName"; my $gcRootsDir = "/nix/var/nix/gcroots/per-container/$containerName";
my $confFile = "/etc/containers/$containerName.conf"; my $confFile = "/etc/containers/$containerName.conf";
if (!-e $confFile) { if (!-e $confFile) {
exit 0 if $action eq "destroy"; if ($action eq "destroy") {
exit 0;
} else {
print "gone\n";
}
die "$0: container $containerName does not exist\n" ; die "$0: container $containerName does not exist\n" ;
} }
@ -190,6 +195,10 @@ elsif ($action eq "stop") {
stopContainer; stopContainer;
} }
elsif ($action eq "status") {
print isContainerRunning() ? "up" : "down", "\n";
}
elsif ($action eq "update") { elsif ($action eq "update") {
my $nixosConfigFile = "$root/etc/nixos/configuration.nix"; my $nixosConfigFile = "$root/etc/nixos/configuration.nix";