diff --git a/check_webservice_load.sh b/check_webservice_load.sh index 338ffc8..70e421d 100755 --- a/check_webservice_load.sh +++ b/check_webservice_load.sh @@ -885,6 +885,13 @@ stop_postgresql() { break fi + # - Don't Start/Stop/Kill Services if package management is running (apt,aptitude,dpkg) + # - + if ( [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ) \ + && $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then + warn "It seems that package management (apt,dpkg) is running. Exiting '${FUNCNAME[0]}' now.." + return 1 + fi kill $PSQL_MAIN_PID > /dev/null 2>&1 sleep 2 @@ -907,6 +914,13 @@ stop_postgresql() { error "Found processes 'postgres:'." info "Going to kill processes 'postgres:'.." + # - Don't Start/Stop/Kill Services if package management is running (apt,aptitude,dpkg) + # - + if ( [[ "${os_dist,,}" = "debian" ]] || [[ "${os_dist,,}" = "ubuntu" ]] ) \ + && $(lsof /var/lib/dpkg/lock >/dev/null 2>&1) ; then + warn "It seems that package management (apt,dpkg) is running. Exiting '${FUNCNAME[0]}' now.." + return 1 + fi for _PID in $CHILD_PIDS ; do kill $_PID > /dev/null 2>&1 done