From: Kruti Pendharkar Date: Wed, 8 Jan 2025 06:05:52 +0000 (-0800) Subject: vm_support update: gather log files based on the current tools.conf X-Git-Tag: stable-13.0.0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7c7bd3ff8fdf85dac4df1be3d275f22cd8fda0a;p=thirdparty%2Fopen-vm-tools.git vm_support update: gather log files based on the current tools.conf configuration The script's revised logic replaces the (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 '${\}' syntax in the data field. The usage/help message for the subcommand "get \section> [key]" has also been updated. --- diff --git a/open-vm-tools/scripts/common/vm-support b/open-vm-tools/scripts/common/vm-support index 9813ac614..481747e18 100644 --- a/open-vm-tools/scripts/common/vm-support +++ b/open-vm-tools/scripts/common/vm-support @@ -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 + # '${\}' 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 $@ diff --git a/open-vm-tools/toolbox/l10n/en.vmsg b/open-vm-tools/toolbox/l10n/en.vmsg index 4962cf172..d9ff86c03 100644 --- a/open-vm-tools/toolbox/l10n/en.vmsg +++ b/open-vm-tools/toolbox/l10n/en.vmsg @@ -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 \n\nSubcommands:\n get
: display all the key values in the
\n get
: display current value for \n NOTE: If the is not present in tools.conf, its\n value from the global configuration is returned if present\n set
: set to \n\n remove
: remove \n\n
can be any supported section, such as logging, guestoperations or guestinfo.\n can be any configuration key.\n can be any value.\n" +help.config = "%1$s: modify Tools configuration\nUsage: %2$s %3$s \n\nSubcommands:\n get
[key] : display current value for given or display values for all keys in
\n NOTE: If the is not present in tools.conf, its\n value from the global configuration is returned if present\n set
: set to \n remove
: remove \n\n
can be any supported section, such as logging, guestoperations or guestinfo.\n can be any configuration key.\n can be any value.\n" help.device = "%1$s: functions related to the virtual machine's hardware devices\nUsage: %2$s %3$s [args]\ndev is the name of the device.\n\nSubcommands:\n enable : enable the device dev\n disable : disable the device dev\n list: list all available devices\n status : print the status of a device\n" diff --git a/open-vm-tools/toolbox/toolboxcmd-config.c b/open-vm-tools/toolbox/toolboxcmd-config.c index 586567a72..fb7e7259c 100644 --- a/open-vm-tools/toolbox/toolboxcmd-config.c +++ b/open-vm-tools/toolbox/toolboxcmd-config.c @@ -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 \n\n" "Subcommands:\n" - " get
: display all the key values in the
\n" - " get
: display current value for \n" + " get
[key] : display current value for given or display values for all keys in
\n" " NOTE: If the is not present in tools.conf, its\n" " value from the global configuration is returned if present\n" - " set
: set to \n\n" + " set
: set to \n" " remove
: remove \n\n" "
can be any supported section, such as logging, guestoperations or guestinfo.\n" " can be any configuration key.\n"