libk  build-id.sh at [112ee76a31]

File global/build-id.sh artifact 45c1076b3a part of check-in 112ee76a31


#!/usr/bin/env bash
source global/common.sh

origin=1566169297
now=$(date +%s)
delta=$(expr $now - $origin)


if test "$id_mode" = "private"; then
	# for privacy's sake, we're not to show
	# the hostname. instead, we calculate a
	# hash based on the  time delta and the
	# output of uname -a for extra entropy
	if has "$HASH"; then
		hash="$HASH"
	elif has sha1; then
		hash=sha1
	elif has sha1sum; then
		hash=sha1sum
	else
		say "cannot find a hashing function; privacy mode cannot be used"
		exit 1
	fi

	h=$(printf "%x%s" "$delta" "$(uname -a)" | $hash)
	echo ${h:1:7}
else
	printf "%x:%s" $delta $(uname -n)
fi