]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Reduce or eliminate Linux dependency on the "net-tools" package.
authorJohn Wolfe <jwolfe@vmware.com>
Thu, 4 Mar 2021 21:48:46 +0000 (13:48 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Thu, 4 Mar 2021 21:48:46 +0000 (13:48 -0800)
The "ifconfig" and "netstat" commands are deprecated in more recent
releases of Linux.  Update the Linux vm-support script to use the "ip"
and "ss" commands when available.

If Available:         Fallback:
     ip                   ifconfig
     ip route             route
     ss                   netstat

Addresses: https://github.com/vmware/open-vm-tools/issues/446

open-vm-tools/scripts/common/vm-support

index 18786534e31c29ff1508027da4aff1a849f144d5..f8e3b29b2505a1de3340b5d95523c6dd61fe7520 100644 (file)
@@ -216,8 +216,6 @@ stageLinux()
    if which apt > /dev/null; then
       runcmd "/tmp/apt-list.txt" apt list
    fi
-   runcmd "/tmp/netstat-lan.txt" netstat -lan
-   runcmd "/tmp/route.txt" route
    runcmd "/tmp/free.txt" free
 }
 
@@ -260,6 +258,22 @@ cleanup()
    fi
 }
 
+collectNetworkDetails()
+{
+    if which ip >/dev/null; then
+        runcmd "/tmp/ip-addr.txt" ip addr
+        runcmd "/tmp/ip-route.txt" ip route
+    else
+        runcmd "/tmp/ifconfig.txt" ifconfig -a
+        runcmd "/tmp/route.txt" route
+    fi
+
+    if which ss >/dev/null; then
+        runcmd "/tmp/ss-lan.txt" ss -lan
+    else
+        runcmd "/tmp/netstat-lan.txt" netstat -lan
+    fi
+}
 
 # This executable may run with root privileges, so hardcode a PATH where
 # unprivileged users cannot write.
@@ -350,7 +364,7 @@ addfile /var/log/cloud-init-output.log
 addfile /etc/cloud/cloud.cfg
 
 runcmd "/tmp/df.txt" df
-runcmd "/tmp/ifconfig.txt" ifconfig -a
+collectNetworkDetails
 runcmd "/tmp/mount.txt" mount
 runcmd "/tmp/dmesg.txt" dmesg
 runcmd "/tmp/ulimit-a.txt" ulimit -a