From 12786cf3f30d02291a4f11d787c2948ff6e39185 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Mon, 10 Jan 2022 10:52:28 +0100 Subject: [PATCH] _wait_for_free_slot: exclude ssh calls --- cm.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cm.sh b/cm.sh index bda9694..e839fe5 100755 --- a/cm.sh +++ b/cm.sh @@ -24,6 +24,7 @@ # 2021-07-14 <axel.hahn@iml.unibe.ch> added _wait_for_free_slot in cert actions to execute multiple processes sequentially # 2021-09-27 <axel.hahn@iml.unibe.ch> softer behaviour: do not revoke changed certs (add does not stop; ensure does not delete) # 2021-12-23 <axel.hahn@iml.unibe.ch> added param --trace as 1st param to generate a trace log +# 2022-01-10 <axel.hahn@iml.unibe.ch> _wait_for_free_slot: exclude ssh calls # ====================================================================== @@ -130,9 +131,9 @@ function _certTransfer(){ # internal function; show md5 hashsums for certificate, csr and key # for visual comparison if the match function _certMatching(){ - local md5_csr=$( test -f ${CM_filecsr} & openssl req -noout -modulus -in ${CM_filecsr} | openssl md5 | cut -f 2 -d " " ) - local md5_key=$( test -f ${CM_outfile_key} & openssl rsa -noout -modulus -in ${CM_outfile_key} | openssl md5 | cut -f 2 -d " " ) - local md5_cert=$( test -f ${CM_outfile_cert} & openssl x509 -noout -modulus -in ${CM_outfile_cert} | openssl md5 | cut -f 2 -d " " ) + local md5_csr=$( test -f ${CM_filecsr} && openssl req -noout -modulus -in ${CM_filecsr} | openssl md5 | cut -f 2 -d " " ) + local md5_key=$( test -f ${CM_outfile_key} && openssl rsa -noout -modulus -in ${CM_outfile_key} | openssl md5 | cut -f 2 -d " " ) + local md5_cert=$( test -f ${CM_outfile_cert} && openssl x509 -noout -modulus -in ${CM_outfile_cert} | openssl md5 | cut -f 2 -d " " ) echo echo "--- compare hashes" @@ -263,13 +264,13 @@ function _wait_for_free_slot(){ _wd "--- Need to wait until own process PID $$ is on top ... " while [ $_bWait = true ]; do - _iFirstPID=$( ps -ef | grep "bash.*$0" | grep -v "grep" | sort -k 2 -n | head -1 | awk '{ print $2}' ) + _iFirstPID=$( ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n | head -1 | awk '{ print $2}' ) if [ $_iFirstPID -eq $$ ]; then _bWait=false _wd "OK. Go!" else _wd "- all instances" - test ${showdebug} && ps -ef | grep "bash.*$0" | grep -v "grep" | sort -k 2 -n + test ${showdebug} && ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n sleep 10 fi done -- GitLab