[Asterisk-code-review] ast coredumper: Fix output directory and variable precedence (asterisk[13])

George Joseph asteriskteam at digium.com
Tue May 15 08:49:37 CDT 2018


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/8991


Change subject: ast_coredumper:  Fix output directory and variable precedence
......................................................................

ast_coredumper:  Fix output directory and variable precedence

The OUTPUTDIR variable in ast_debug_tools.conf.sample is now set
to "/tmp" instead of "/some/directory".

Variables set on the command line or that are already in the
environment now take predecence over variables set in the config files.

ASTERISK-27846
Reported by: Ted G

Change-Id: Ie8baec52d531886bf5849ec1d59bb59dc87ad387
---
M configs/samples/ast_debug_tools.conf.sample
M contrib/scripts/ast_coredumper
2 files changed, 17 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/91/8991/1

diff --git a/configs/samples/ast_debug_tools.conf.sample b/configs/samples/ast_debug_tools.conf.sample
index 1c4827f..0f90f85 100644
--- a/configs/samples/ast_debug_tools.conf.sample
+++ b/configs/samples/ast_debug_tools.conf.sample
@@ -24,7 +24,7 @@
 # For output from existing core files, the default is the
 # directory that the core file is found in.  For core files
 # produced from a running process, the default is /tmp.
-OUTPUTDIR=/some/directory
+OUTPUTDIR=/tmp
 
 # Date command for the "running" coredump and tarballs.
 # DATEFORMAT will be executed to get the timestamp.
diff --git a/contrib/scripts/ast_coredumper b/contrib/scripts/ast_coredumper
index 38d95cc..c74b369 100755
--- a/contrib/scripts/ast_coredumper
+++ b/contrib/scripts/ast_coredumper
@@ -225,10 +225,22 @@
 declare -a COREDUMPS
 declare -a ARGS_COREDUMPS
 
-# Read config files from least important to most important
-[ -f /etc/asterisk/ast_debug_tools.conf ] && source /etc/asterisk/ast_debug_tools.conf
-[ -f ~/ast_debug_tools.conf ] && source ~/ast_debug_tools.conf
-[ -f ./ast_debug_tools.conf ] && source ./ast_debug_tools.conf
+# readconf reads a bash-sourceable file and sets variables
+# that havn't already been set.  This allows variables set
+# on the command line or that are already in the environment
+# to take precedence over those read from the file.
+readconf() {
+	while read line ; do
+		v=${line%%=*}
+		[ ! -v ${v} ] && eval $line || :
+	done <<< $( sed -r -e "/\s*#/d" -e "/^\s*$/d" $1 )
+}
+
+# Read config files from most important to least important.
+# Variable set on the command line or environment always take precedence.
+[ -f ./ast_debug_tools.conf ] && readconf ./ast_debug_tools.conf
+[ -f ~/ast_debug_tools.conf ] && readconf ~/ast_debug_tools.conf
+[ -f /etc/asterisk/ast_debug_tools.conf ] && readconf /etc/asterisk/ast_debug_tools.conf
 
 # For *BSD, the preferred gdb may be in /usr/local/bin so we
 # need to search for one that supports python.

-- 
To view, visit https://gerrit.asterisk.org/8991
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8baec52d531886bf5849ec1d59bb59dc87ad387
Gerrit-Change-Number: 8991
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180515/85c8181c/attachment.html>


More information about the asterisk-code-review mailing list