Update script files

Accept date instead of gdaye if it is actually gnu date
This commit is contained in:
Rob Pearce 2021-12-23 16:28:03 +11:00
parent 6c268c3f3b
commit 4fb75769c3
1 changed files with 23 additions and 13 deletions

View File

@ -163,7 +163,7 @@ function loadcachefile() { # loadcachefile [dc1 dc2 ...]
function uuid_callback() {
nuuids=0
loadcachefile $curlocs
uuidend=$(($(gdate +%s%N)/1000))
uuidend=$(($($GDATE +%s%N)/1000))
uuidsecs=$(echo "scale=2; ($uuidend - $uuidstart) / 1000000;" | bc)
if [[ $nuuids -ge 1 ]]; then
@ -193,7 +193,7 @@ function start_recache_if_needed() {
function start_recache() {
local rv
uuidstart=$(($(gdate +%s%N)/1000))
uuidstart=$(($($GDATE +%s%N)/1000))
if [[ -z $recache_pid ]]; then
# setup callback for uuid cache reload handling
trap uuid_callback SIGUSR1
@ -1157,13 +1157,13 @@ function getbasefilter() { # epidx [regexp_filter]
function profile_start() {
profile "start profiling"
prof_start=$(($(gdate +%s%N)/1000))
prof_start=$(($($GDATE +%s%N)/1000))
prof_last="$prof_start"
}
function profile_mark() {
local now secs
now=$(($(gdate +%s%N)/1000))
now=$(($($GDATE +%s%N)/1000))
secs=$(echo "scale=2; ($now - $prof_last) / 1000000;" | bc)
profile "[+${secs} secs] $* "
prof_last="$now"
@ -1253,7 +1253,7 @@ function runaction() { # runaction <nodes|vms|etc> <actionname> targetlist optio
local jqf_bad='[ "_DC_", "_OB_", .fault.detail, .fault.reason, .status ] | @csv'
local objecttype extrainfo
start=$(($(gdate +%s%N)/1000))
start=$(($($GDATE +%s%N)/1000))
lastqsecs=""
lastprocsecs=""
what="$1"
@ -1380,7 +1380,7 @@ debug "extrainfo is: $extrainfo"
rm -f $TMPDIR/run,*
fi
end=$(($(gdate +%s%N)/1000))
end=$(($($GDATE +%s%N)/1000))
lastqsecs=$(echo "scale=2; ($end - $start) / 1000000;" | bc)
return $rv
}
@ -1408,7 +1408,7 @@ function getdata() { # getdata <nodes|vms|etc> <cmd> options
local errordebug=0
local quiet=0 ignorecase=0
start=$(($(gdate +%s%N)/1000))
start=$(($($GDATE +%s%N)/1000))
lastqsecs=""
lastprocsecs=""
what="$1"
@ -1545,9 +1545,9 @@ debug all pids finished
fi
debug "combined results: [$all]"
end=$(($(gdate +%s%N)/1000))
end=$(($($GDATE +%s%N)/1000))
lastqsecs=$(echo "scale=2; ($end - $start) / 1000000;" | bc)
start=$(($(gdate +%s%N)/1000))
start=$(($($GDATE +%s%N)/1000))
rescount=$(printf %d $(echo -n "$all" | wc -c))
if [[ $rescount -eq 0 ]]; then
@ -1671,7 +1671,7 @@ debug "wantcols is [$wantcols]"
#end=$(($(gdate +%s%N)/1000))
#lastqsecs=$(echo "scale=2; ($end - $start) / 1000000;" | bc)
end=$(($(gdate +%s%N)/1000))
end=$(($($GDATE +%s%N)/1000))
lastprocsecs=$(echo "scale=2; ($end - $start) / 1000000;" | bc)
}
@ -2160,10 +2160,20 @@ function setproject() { # setproject [project_name]
function checkfor() { # checkfor name [pkg_name]
local what pkgname
local os ok=0 confirm=0
local alt rv
what=$1
pkg_name=${2:-$what}
os=$(uname -s)
which $what >/dev/null 2>&1
rv=$?
if [[ $rv -ne 0 && $what == "gdate" ]]; then
date --version 2>/dev/null | grep -q GNU 2>/dev/null
if [[ $? -eq 0 ]] then
GDATE=$(which date)
rv=0
fi
fi
if [[ $? -eq 0 ]]; then
ok=1
else
@ -2367,6 +2377,7 @@ addcmd -a q "Exit from gnscli" 0
VERBOSE=0
GDATE="gdate"
CONFDIR="$HOME/.gnscli"
HISTFILE="$CONFDIR/history"
TMPDIR="$CONFDIR/tmp"
@ -2569,11 +2580,10 @@ END {
"Model UUID#" + .template_id,
"Project UUID#" + .project_id,
"Status#" + .status,
"Console port#" + ((.console|tostring) // "n/a"),
"Locked#" + (.locked // "n/a"),
"Port format#" + .port_name_format,
"Locked#" + (.locked // "n/a"),
"Console port#" + ((.console|tostring) // "n/a"),
"Port count#" + try (.ports[] | length) catch ("unknown"),
"__END__"
#END_INLINE:node.jq
#START_INLINE:link.jq
"UUID#" + .link_id,