From 241040ec7f1a8900b969b46d7cb3329cdf5f4928 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 16 Dec 2021 12:43:06 +0100 Subject: [PATCH] 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 --- sbin/ngcpcfg | 4 ++++ scripts/status | 8 +------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sbin/ngcpcfg b/sbin/ngcpcfg index 7d45eb1d..440fc2b3 100755 --- a/sbin/ngcpcfg +++ b/sbin/ngcpcfg @@ -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 $*" diff --git a/scripts/status b/scripts/status index 917fafe8..b933e3f9 100755 --- a/scripts/status +++ b/scripts/status @@ -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'."