summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2020-05-05 15:50:20 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-08 21:50:45 +0000
commitf4ae1d4259eeff6efaae2d22bf16e7dff4a4f701 (patch)
tree1e41cc2dd9a33c23f2c337c5b8a26ea58643696e
parent7c49b2a463e25c7b402e25270da382aa59e4b92e (diff)
downloadmongo-f4ae1d4259eeff6efaae2d22bf16e7dff4a4f701.tar.gz
SERVER-47927 Ubuntu 20.04 - ifconfig replaced with ip command
(cherry picked from commit 840799ea16600d18131c5b18c0a678d00f31b329)
-rw-r--r--jstests/libs/host_ipaddr.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/jstests/libs/host_ipaddr.js b/jstests/libs/host_ipaddr.js
index 5ff84b0dd2d..1bfb3d146c2 100644
--- a/jstests/libs/host_ipaddr.js
+++ b/jstests/libs/host_ipaddr.js
@@ -15,7 +15,8 @@ function get_ipaddr() {
var ipFile = path + "ipaddr-" + Random.srand() + ".log";
var windowsCmd = "ipconfig > " + ipFile;
- var unixCmd = "/sbin/ifconfig | grep inet | grep -v '127.0.0.1' > " + ipFile;
+ var unixCmd =
+ "(/sbin/ifconfig || /usr/sbin/ip addr) | grep 'inet ' | grep -v '127.0.0.1' > " + ipFile;
var ipAddr = null;
var hostType = null;
@@ -27,8 +28,9 @@ function get_ipaddr() {
runProgram('cmd.exe', '/c', windowsCmd);
ipAddr = cat(ipFile).match(/IPv4.*: (.*)/)[1];
} else {
- runProgram('bash', '-c', unixCmd);
- ipAddr = cat(ipFile).replace(/addr:/g, "").match(/inet (.[^ ]*) /)[1];
+ runProgram('/bin/sh', '-c', unixCmd);
+ ipAddr =
+ cat(ipFile).replace(/addr:/g, "").match(/inet ([\d]+\.[\d]+\.[\d]+\.[\d]+)/)[1];
}
} finally {
removeFile(ipFile);