From a6ea882c2fa670a1b5d0bdcaefb329315c601a53 Mon Sep 17 00:00:00 2001 From: nervuri Date: Sun, 19 Mar 2023 17:21:40 +0000 Subject: [PATCH] output execution duration for each script --- agunua/generate-trust-store.sh | 8 +++++++- amfora/generate-trust-store.sh | 8 +++++++- cert-details.sh | 8 +++++++- get-certs.sh | 8 +++++++- get-hosts.sh | 8 +++++++- lagrange/generate-trust-store.sh | 8 +++++++- main.sh | 8 ++++++++ prune-old-certs.sh | 8 +++++++- 8 files changed, 57 insertions(+), 7 deletions(-) diff --git a/agunua/generate-trust-store.sh b/agunua/generate-trust-store.sh index 9b3273f..10ff1a9 100755 --- a/agunua/generate-trust-store.sh +++ b/agunua/generate-trust-store.sh @@ -22,6 +22,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -76,4 +78,8 @@ for cert_file in ../certs/*; do done -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)" diff --git a/amfora/generate-trust-store.sh b/amfora/generate-trust-store.sh index 9d9bb34..c022e18 100755 --- a/amfora/generate-trust-store.sh +++ b/amfora/generate-trust-store.sh @@ -20,6 +20,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -74,4 +76,8 @@ for cert_file in ../certs/*; do done -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)" diff --git a/cert-details.sh b/cert-details.sh index c431395..cae25c9 100755 --- a/cert-details.sh +++ b/cert-details.sh @@ -6,6 +6,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -56,4 +58,8 @@ done echo "$md_table" > cert-details.md echo "$csv_table" > cert-details.csv -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)" diff --git a/get-certs.sh b/get-certs.sh index 1078581..62f8420 100755 --- a/get-certs.sh +++ b/get-certs.sh @@ -6,6 +6,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -144,4 +146,8 @@ while read -r host; do done < hosts -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)" diff --git a/get-hosts.sh b/get-hosts.sh index 2cb2573..26f7ca8 100755 --- a/get-hosts.sh +++ b/get-hosts.sh @@ -9,6 +9,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -91,4 +93,8 @@ hosts=$(echo "$hosts" | sort) # Save to file. echo "$hosts" > hosts -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)" diff --git a/lagrange/generate-trust-store.sh b/lagrange/generate-trust-store.sh index 3711f16..4a25258 100755 --- a/lagrange/generate-trust-store.sh +++ b/lagrange/generate-trust-store.sh @@ -22,6 +22,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -71,4 +73,8 @@ for cert_file in ../certs/*; do done -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)" diff --git a/main.sh b/main.sh index 898095f..487a583 100755 --- a/main.sh +++ b/main.sh @@ -4,6 +4,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit status +timestamp_start=$(date +%s) + # Check if dependencies are installed. if ! command -v openssl >/dev/null; then >&2 echo '"openssl" not installed! [required]' @@ -50,3 +52,9 @@ echo '=== Lagrange ===' lagrange/generate-trust-store.sh echo "End -> $(date --utc)" + +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "Total duration: $exec_time_formatted" diff --git a/prune-old-certs.sh b/prune-old-certs.sh index 7dfc422..f0252ba 100755 --- a/prune-old-certs.sh +++ b/prune-old-certs.sh @@ -8,6 +8,8 @@ set -o errexit # (-e) exit immediately if any command has a non-zero exit statu set -o nounset # (-u) don't accept undefined variables #set -o xtrace # for debugging +timestamp_start=$(date +%s) + # Go where this script is. cd "$(dirname "$0")" || exit @@ -29,4 +31,8 @@ find certs -mtime +30 -type f -execdir sh -c ' fi ' sh {} \; -echo OK +timestamp_end=$(date +%s) +exec_time="$((timestamp_end - timestamp_start))" +exec_time_formatted="$(date -d "@$exec_time" --utc "+%H:%M:%S")" + +echo "OK (duration: $exec_time_formatted)"