Skip to content

Commit

Permalink
Use own version of prettyuptime
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavid committed Aug 8, 2023
1 parent d150031 commit 9b91f74
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions app/gento
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BASE_APP_USAGE="$(
}
readonly \
BASE_APP_USAGE \
BASE_APP_VERSION=0.9.20230731 \
BASE_APP_VERSION=0.9.20230808 \
BASE_MIN_VERSION=0.9.20230606
. base.sh

Expand Down Expand Up @@ -343,7 +343,7 @@ node_version() {
dmidecode -s system-manufacturer 2>&1 &&
dmidecode -s system-product-name 2>&1 &&
hostname 2>&1 &&
$(which prettyuptime); prettyuptime" 2>&1
$(which puptime); puptime" 2>&1
)" || die Unable to run debug pod at node "$node": "$out"
manufac="$(printf %s "$out" | tail -4 | head -1 | xargs)"
manufac="${manufac:=$err}"
Expand Down Expand Up @@ -410,6 +410,26 @@ parse_input() {
readonly CFG CNF
}

# Displays uptime in a human-readable format. The similar function prettyuptime
# from Shellbase framework has additional dependencies and cannot be executed
# in a node as is.
puptime() {
uptime | sed -E '
s/^[^,]*up *//
s/mins/minutes/
s/hrs?/hours/
s/([[:digit:]]+):0?([[:digit:]]+)/\1 hours, \2 minutes/
s/^1 hours/1 hour/
s/ 1 hours/ 1 hour/
s/min,/minutes,/
s/ 0 minutes,/ less than a minute,/
s/ 1 minutes/ 1 minute/
s/ / /
s/, *[[:digit:]]* users?.*//
s/^/↑ /
' | tr -d \\n
}

# Gets local system information.
read_info() {
CNFA="$CNF"
Expand Down

0 comments on commit 9b91f74

Please sign in to comment.