nixos-container: Make show-ip work together with ipv4 + netmask

The containers local address can be given as ipv4 only or with a subnetmask in
CIDR notation in the container configuration, see [1]. This works fine but the
'nixos-container show-ip' only supports plain ipv4 addresses without the netmask
suffix.

Changed the regex to also match in case of a CIDR netmask suffix.

[1] 9939032e35/nixos/modules/virtualisation/containers.nix (L382)
This commit is contained in:
Martin Bornhold 2017-11-16 13:55:20 +01:00
parent 55851579d9
commit ac7edeebfd

View file

@ -331,7 +331,7 @@ elsif ($action eq "run") {
elsif ($action eq "show-ip") {
my $s = read_file($confFile) or die;
$s =~ /^LOCAL_ADDRESS=([0-9\.]+)$/m or die "$0: cannot get IP address\n";
$s =~ /^LOCAL_ADDRESS=([0-9\.]+)(\/[0-9]+)?$/m or die "$0: cannot get IP address\n";
print "$1\n";
}