# 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
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
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 $@
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"
"%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"