diff --git a/includes/dbdetect.class.sh b/includes/dbdetect.class.sh index c049b2bad88c62057914e8f7292598df23b1171a..2a12e9d0c686637a25b3ac26c042fa546bbf90bf 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