From 1dd06659377cf208ad3ac685719fa396960f80cc Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Thu, 23 Dec 2021 12:02:17 +0100 Subject: [PATCH] added param --trace as 1st param --- cm.sh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/cm.sh b/cm.sh index 4f841d7..bda9694 100755 --- a/cm.sh +++ b/cm.sh @@ -23,6 +23,7 @@ # 2021-06-24 <axel.hahn@iml.unibe.ch> added transfer command; delete files if acme.sh --install-cert ... failes # 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 # ====================================================================== @@ -32,8 +33,9 @@ # # ---------------------------------------------------------------------- -touchfile="./log/lastchange.txt" -logfile="./log/certmanager.log" +logdir="./log" +touchfile="$logdir/lastchange.txt" +logfile="$logdir/certmanager.log" csrfile="./templates/csr.txt" @@ -569,6 +571,19 @@ function public_transfer(){ cd $( dirname $0 ) +if [ "$1" = "--trace" ]; then + tracelog="$logdir/trace__$2__$3__`date +%Y-%m-%d__%H-%M-%S`.log" + exec > >(tee -a ${tracelog} ) + exec 2> >(tee -a ${tracelog} >&2) + echo "TRACELOG was triggered." + echo "TIME : $(date)" + echo "COMMAND: $0 $*" + echo "LOG : $tracelog" + + # set -vx + shift 1 +fi + cat <<ENDOFHEADER $line @@ -621,7 +636,7 @@ else HELP The basic syntax is -$self ACTION [FQDN] [ALIAS_1 [.. ALIAS_N]] +$self [--trace] ACTION [FQDN] [ALIAS_1 [.. ALIAS_N]] The ACTIONs for SINGLE certificate handlings are: @@ -675,6 +690,11 @@ other ACTIONs check of health with current setup and requirements. This command is helpful for initial setups. +OPTIONS + --trace (it must be the 1st parameter) + the output additionally will be written into a tracelog file + below $logdir. + EOF fi -- GitLab