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
changes/80/24180/1
Alexander Lutay 7 years ago
parent a2edb11597
commit b9c6270ba2

@ -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:-}: $*"
}
# }}}

Loading…
Cancel
Save