Skip to content

Commit

Permalink
Added execution time hitachienergy#536
Browse files Browse the repository at this point in the history
  • Loading branch information
to-bar committed Oct 7, 2019
1 parent d62e3f0 commit a9a0da7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# VERSION 1.2.2
# VERSION 1.2.3

set -euo pipefail

Expand Down Expand Up @@ -60,6 +60,17 @@ create_directory() {
fi
}

# params: <seconds>
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: <file_url> <dest_dir>
download_file() {
local file_url="$1"
Expand Down Expand Up @@ -302,6 +313,7 @@ usage() {
# === Start ===

[ $# -gt 0 ] || usage 1 >&2
readonly START_TIME=$(date +%s)

# --- Parse arguments ---

Expand Down Expand Up @@ -576,4 +588,6 @@ done
# --- Clean up packages ---
remove_installed_packages "$INSTALLED_PACKAGES_FILE_PATH"

echol "$(basename $0) finished"
readonly END_TIME=$(date +%s)

echol "$(basename $0) finished in $(display_seconds $((START_TIME-END_TIME)))"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# VERSION 1.2.2
# VERSION 1.2.3

set -euo pipefail

Expand Down Expand Up @@ -60,6 +60,17 @@ create_directory() {
fi
}

# params: <seconds>
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: <file_url> <dest_dir>
download_file() {
local file_url="$1"
Expand Down Expand Up @@ -319,6 +330,7 @@ usage() {
# === Start ===

[ $# -gt 0 ] || usage 1 >&2
readonly START_TIME=$(date +%s)

# --- Parse arguments ---

Expand Down Expand Up @@ -599,4 +611,6 @@ done
# --- Clean up packages ---
remove_installed_packages "$INSTALLED_PACKAGES_FILE_PATH"

echol "$(basename $0) finished"
readonly END_TIME=$(date +%s)

echol "$(basename $0) finished in $(display_seconds $((START_TIME-END_TIME)))"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9a0da7

Please sign in to comment.