From 0a3e7a21dfad777c7b52fa22253a79de94a58f5c Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Mon, 11 Mar 2024 15:38:26 +0100 Subject: [PATCH] add function dbdetect._requireProcess --- includes/dbdetect.class.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/includes/dbdetect.class.sh b/includes/dbdetect.class.sh index c049b2b..2a12e9d 100644 --- a/includes/dbdetect.class.sh +++ b/includes/dbdetect.class.sh @@ -31,6 +31,25 @@ function dbdetect._wd(){ test "$DBD_DEBUG" -ne "0" && color.echo "darkgray" "DEBUG: $*" >&2 } +# check if a process name exisats +# param string regex to find in ps -ef output +# param bool flag to skip; default: none = abort on miss +function dbdetect._requireProcess(){ + # echo "CHECK process $1" + # ps -ef | grep -v grep | grep -E "$1" >/dev/null + pgrep -l "$1" >/dev/null + rcself=$? + if [ $rcself -ne 0 ]; then + rc=$rc+$rcself + echo "INFO: missing process $1" + if [ -z "$2" ]; then + exit 4 + fi + return 1 + fi + return 0 +} + # get a list of all config files # param string full path of ini file function dbdetect.getConfigs(){ @@ -89,7 +108,7 @@ function dbdetect.exists(){ local binary; binary=$( ini.value "binary" ) if [ -n "${binary}" ]; then for mybinary in $( echo "${binary}" | tr "," " " ); do - if ! j_requireBinary "$mybinary" 1 >/dev/null 2>&1; then + if ! dbdetect._requireProcess "$mybinary" 1 >/dev/null 2>&1; then dbdetect._wd "... Missing binary: ${mybinary}" return 1 fi -- GitLab