From b9c6270ba272a61b03320e876e5eea1c87471e06 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 12 Oct 2018 10:18:03 +0200 Subject: [PATCH] TT#45613 Improve a2edb11: debug messages can be printed before $HNAME is initialised The night Carrier trunk installation has failed: > +02:29:59 (cfg_pro.inc:280): cfg_ngcpcfg_init_mgmt(): cfg_ensure_file_mgmt_node > ... > +02:29:59 (cfg_pro.inc:282): cfg_ngcpcfg_init_mgmt(): '[' -x /usr/share/ngcp-ngcpcfg/scripts/init-mgmt ']' > +02:29:59 (cfg_pro.inc:287): cfg_ngcpcfg_init_mgmt(): DEBUG=yes > +02:29:59 (cfg_pro.inc:287): cfg_ngcpcfg_init_mgmt(): /usr/share/ngcp-ngcpcfg/scripts/init-mgmt > /usr/share/ngcp-ngcpcfg/functions//main: line 18: HNAME: unbound variable The manual execution of script 'init-mgmt' shows no error, so far if 'DEBUG=yes' is enabled the issue is easily reproducible. The reason here is debug messages which can be printed on the very early stage of initialisation and cause the issue here: > ++ log_debug 'sourced configuration file /etc/ngcp-config/ngcpcfg.cfg' > ++ '[' -n yes ']' > ++ logger -t ngcpcfg -- 'Debug: sourced configuration file /etc/ngcp-config/ngcpcfg.cfg' > ++ console_output 'DEBUG: sourced configuration file /etc/ngcp-config/ngcpcfg.cfg\n' > ++ '[' -z '+%F %T' ']' > +++ date '+%F %T' > ++ local 'timestamp=2018-10-12 10:16:24' > +++ printf -- '%s: ' '2018-10-12 10:16:24' > +++ sed 's/./ /g' > ++ timestamp_replacementchars=' ' > /usr/share/ngcp-ngcpcfg/functions//main: line 18: HNAME: unbound variable Let's be polite for such kind of log message. Change-Id: I3647567aba5fad3a103af2e6da35229f6d932bed --- functions/main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/main b/functions/main index b3d4c3e6..8a83e5ea 100644 --- a/functions/main +++ b/functions/main @@ -15,7 +15,7 @@ console_output() { # indent depending on number of characters in date output timestamp_replacementchars="$(printf -- "%s: " "$timestamp" | sed 's/./ /g')" - printf -- "$timestamp $HNAME: $*" + printf -- "$timestamp ${HNAME:-}: $*" } # }}}