diff --git a/cm.sh b/cm.sh index bda9694e5a96cd7ef6177896bbb6117177f739ef..e839fe5001bea0370f4896e7c09c6b8f6fa0b165 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