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] https://github.com/NixOS/nixpkgs/blob/9939032e35bb144bc8f6b57ed6325089910f738c/nixos/modules/virtualisation/containers.nix#L382
commitac7edeebfd4ca45d4c6569f36dc5d6dd10aa58e9
authorMartin Bornhold <mb@bo-tech.de>
dateThu 16 Nov 2017, 13:55 (9 years ago)
parent5585157
pkgs/tools/virtualization/nixos-container/nixos-container.pl+1−1
@@ -331,7 +331,7 @@ elsif ($action eq "run") {
331331
332332elsif ($action eq "show-ip") {
333333 my $s = read_file($confFile) or die;
334− $s =~ /^LOCAL_ADDRESS=([0-9\.]+)$/m or die "$0: cannot get IP address\n";
334+ $s =~ /^LOCAL_ADDRESS=([0-9\.]+)(\/[0-9]+)?$/m or die "$0: cannot get IP address\n";
335335 print "$1\n";
336336}
337337