From a9a0da7ec76d1fd4d24956cbbb95605f992ba260 Mon Sep 17 00:00:00 2001 From: to-bar <46519524+to-bar@users.noreply.github.com> Date: Mon, 7 Oct 2019 14:06:17 +0200 Subject: [PATCH] Added execution time #536 --- .../centos-7/download-requirements.sh | 18 ++++++++++++++++-- .../redhat-7/download-requirements.sh | 18 ++++++++++++++++-- .../repository/tasks/download-requirements.yml | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/download-requirements.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/download-requirements.sh index e67d4659f6..1659e11248 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/download-requirements.sh +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/centos-7/download-requirements.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# VERSION 1.2.2 +# VERSION 1.2.3 set -euo pipefail @@ -60,6 +60,17 @@ create_directory() { fi } +# params: +display_seconds() { + local seconds=$1 + local h=$((seconds/3600)) + local m=$((seconds%3600/60)) + local s=$((seconds%60)) + (( h > 0 )) && printf '%dh ' $h + (( m > 0 )) && printf '%dm ' $m + printf '%ds' $s +} + # params: download_file() { local file_url="$1" @@ -302,6 +313,7 @@ usage() { # === Start === [ $# -gt 0 ] || usage 1 >&2 +readonly START_TIME=$(date +%s) # --- Parse arguments --- @@ -576,4 +588,6 @@ done # --- Clean up packages --- remove_installed_packages "$INSTALLED_PACKAGES_FILE_PATH" -echol "$(basename $0) finished" \ No newline at end of file +readonly END_TIME=$(date +%s) + +echol "$(basename $0) finished in $(display_seconds $((START_TIME-END_TIME)))" \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/download-requirements.sh b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/download-requirements.sh index d3870ec996..d714ed53c7 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/download-requirements.sh +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/files/download-requirements/redhat-7/download-requirements.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# VERSION 1.2.2 +# VERSION 1.2.3 set -euo pipefail @@ -60,6 +60,17 @@ create_directory() { fi } +# params: +display_seconds() { + local seconds=$1 + local h=$((seconds/3600)) + local m=$((seconds%3600/60)) + local s=$((seconds%60)) + (( h > 0 )) && printf '%dh ' $h + (( m > 0 )) && printf '%dm ' $m + printf '%ds' $s +} + # params: download_file() { local file_url="$1" @@ -319,6 +330,7 @@ usage() { # === Start === [ $# -gt 0 ] || usage 1 >&2 +readonly START_TIME=$(date +%s) # --- Parse arguments --- @@ -599,4 +611,6 @@ done # --- Clean up packages --- remove_installed_packages "$INSTALLED_PACKAGES_FILE_PATH" -echol "$(basename $0) finished" \ No newline at end of file +readonly END_TIME=$(date +%s) + +echol "$(basename $0) finished in $(display_seconds $((START_TIME-END_TIME)))" \ No newline at end of file diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml index ac6b9cc29a..fd9f300a7d 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/download-requirements.yml @@ -24,7 +24,7 @@ Run download-requirements script, it can take a long time You can check progress on repository host with: journalctl -f -t download-requirements.sh shell: >- - set -o pipefail && time /tmp/epi-download-requirements/download-requirements.sh /var/www/html/epirepo --no-logfile |& + set -o pipefail && /tmp/epi-download-requirements/download-requirements.sh /var/www/html/epirepo --no-logfile |& tee >(systemd-cat --identifier=download-requirements.sh) args: executable: /bin/bash