TT#102912 Provide invocation name of ngcpcfg to subprocesses

Instead of having to identify the parent process name (ngcpcfg vs.
ngcp-config) inside subprocesses (like "status"), let's provide the
invocation name through the main ngcpcfg binary via variable
NGCPCFG_NAME.

Thanks to Guillem Jover for the suggestion.

Change-Id: Iafbac535bedb9cc9dc73f3d95861a5bc735cc739
mr10.3.1
Michael Prokop 4 years ago
parent 664ad7ddfe
commit 241040ec7f

@ -111,6 +111,10 @@ fi
# Notify subprocesses we are running.
export NGCPCFG_RUNNING=1
# Provide invocation name (ngcpcfg vs. ngcp-config) to subprocesses/scripts
NGCPCFG_NAME="$(basename "$0")"
export NGCPCFG_NAME
export NGCPCFG_PID=$$
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "******************************************************"
logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Running: $0 $*"

@ -52,13 +52,7 @@ check_local_state() {
log_debug "cd $NGCPCTL_MAIN"
cd "$NGCPCTL_MAIN"
# report either "ngcpcfg" or "ngcp-config", depending on how it was invoked
local invoker
if [ -r "/proc/${PPID:-doesnotexist}/comm" ] ; then
invoker="$( < /proc/$PPID/comm)"
fi
log_info "Checking state of ${invoker:-ngcpcfg}:"
log_info "Checking state of ${NGCPCFG_NAME:-ngcpcfg}:"
if ! [ -r "${NGCPCTL_MAIN}/.git/HEAD" ] ; then
log_warn "ngcpcfg has not been initialised yet. Execute 'ngcpcfg initialise'."

Loading…
Cancel
Save