]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
vm_support update: gather log files based on the current tools.conf
authorKruti Pendharkar <kp025370@broadcom.com>
Wed, 8 Jan 2025 06:05:52 +0000 (22:05 -0800)
committerKruti Pendharkar <kp025370@broadcom.com>
Wed, 8 Jan 2025 06:05:52 +0000 (22:05 -0800)
configuration

The script's revised logic replaces the <variable>(s) in the data field
value (logfile name) with a wildcard ('*') character, and it escapes the
'$' sign in the sed match pattern to match the '${\<variable>}' syntax
in the data field.

The usage/help message for the subcommand "get \section> [key]" has also
been updated.

open-vm-tools/scripts/common/vm-support
open-vm-tools/toolbox/l10n/en.vmsg
open-vm-tools/toolbox/toolboxcmd-config.c

index 9813ac614c7fb55482ed99f3e4ba7e5333a7b0e0..481747e1864f18ba2ce5569b1c7d2ce56a346e87 100644 (file)
@@ -136,6 +136,9 @@ addfiles()
 
 # Get the log files mentioned in the logging section of tools.conf. Get the log
 # archive file names
+# The 3 $variables in tools.conf that are expanded by components using them are
+# ${USER}, ${PID}, ${IDX}
+# Any other $vars are treated literally
 # The archive logic for these logs files seems to be this. Below is one example:
 #     if vmtoolsd.data = vmtoolsd.log
 #       then the file is backed up as vmtoolsd.1.log vmtoolsd.2.log etc
@@ -146,18 +149,19 @@ addfiles()
 addLogFiles()
 {
    IFS=""
-   vmware-toolbox-cmd config get logging | grep "\.data =" | cut -d"=" -f2 | while read -r logFile; do
-      logFile=`eval echo "$logFile"`
-      if [ -z "$logFile" ]; then
-         continue
-      fi
-
-      # trim the leading spaces
-      logFile=`echo $logFile | sed 's/^ *//'`
+   # get the key value pair from tools.conf
+   # Replace the $variables in the data field value (logfile name) with a
+   # wildcard ('\*') character. Remove the leading whitespaces from the resulting
+   # value.  The '$' is escaped in the sed match pattern to match
+   # '${\<variable-name\>}' literally.
+   vmware-toolbox-cmd config get logging | grep "\.data =" | cut -d"=" -f2 | sed 's/\${.*}/\\\*/g' | sed 's/^ *//' | while read -r logFile; do
       dirName=`dirname $logFile`
       fileName=`basename $logFile`
 
-      #find and add the current logs
+      # Remove the escape char \ that was added above
+      fileName=$(echo $fileName | sed 's/\\//g')
+
+      # find and add the current logs
       find "$dirName" -maxdepth 1 -name "$fileName" -print | while read -r logFile; do
          addfile "$logFile"
       done
@@ -305,7 +309,7 @@ collectNetworkDetails()
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
 TARFILE=vm-`date +%Y-%m-%d`.$$.tar.gz
-VER=0.96
+VER=0.97
 
 # Parse args
 for option in $@
index 4962cf172fbb288ff101bc57eec951a8054aa3f4..d9ff86c03f2124a3816ec84210ad28230e4cc2ae 100644 (file)
@@ -93,7 +93,7 @@ error.novirtual = "%1$s must be run inside a virtual machine.\n"
 
 error.unknown = "%1$s: Unknown %2$s '%3$s'\n"
 
-help.config = "%1$s: modify Tools configuration\nUsage: %2$s %3$s <subcommand>\n\nSubcommands:\n   get <section> : display all the key values in the <section>\n   get <section> <key>: display current value for <key>\n   NOTE: If the <key> is not present in tools.conf, its\n   value from the global configuration is returned if present\n   set <section> <key> <value>: set <key> to <value>\n\n   remove <section> <key>: remove <key>\n\n<section> can be any supported section, such as logging, guestoperations or guestinfo.\n<key> can be any configuration key.\n<value> can be any value.\n"
+help.config = "%1$s: modify Tools configuration\nUsage: %2$s %3$s <subcommand>\n\nSubcommands:\n   get <section> [key] : display current value for given <key> or display values for all keys in <section>\n   NOTE: If the <key> is not present in tools.conf, its\n   value from the global configuration is returned if present\n   set <section> <key> <value>: set <key> to <value>\n   remove <section> <key>: remove <key>\n\n<section> can be any supported section, such as logging, guestoperations or guestinfo.\n<key> can be any configuration key.\n<value> can be any value.\n"
 
 help.device = "%1$s: functions related to the virtual machine's hardware devices\nUsage: %2$s %3$s <subcommand> [args]\ndev is the name of the device.\n\nSubcommands:\n   enable <dev>: enable the device dev\n   disable <dev>: disable the device dev\n   list: list all available devices\n   status <dev>: print the status of a device\n"
 
index 586567a725a48828b30fe2666d038d516372d135..fb7e7259c904357574431908045e03c003aaa083 100644 (file)
@@ -320,11 +320,10 @@ Config_Help(const char *progName, // IN: The name of the program obtained from a
                "%s: modify Tools configuration\n"
                "Usage: %s %s <subcommand>\n\n"
                "Subcommands:\n"
-               "   get <section> : display all the key values in the <section>\n"
-               "   get <section> <key>: display current value for <key>\n"
+               "   get <section> [key] : display current value for given <key> or display values for all keys in <section>\n"
                "   NOTE: If the <key> is not present in tools.conf, its\n"
                "   value from the global configuration is returned if present\n"
-               "   set <section> <key> <value>: set <key> to <value>\n\n"
+               "   set <section> <key> <value>: set <key> to <value>\n"
                "   remove <section> <key>: remove <key>\n\n"
                "<section> can be any supported section, such as logging, guestoperations or guestinfo.\n"
                "<key> can be any configuration key.\n"