# Avoid entropy starvation (#923675):

log() {
	logger -t entropy-source "$@"
}

if [ -x /usr/sbin/haveged ]; then
	if grep -q '^flags\b.*\brdrand\b' /proc/cpuinfo; then
		log 'haveged not needed: rdrand CPU flag detected'
	elif [ "$(cat /sys/devices/virtual/misc/hw_random/rng_current 2>/dev/null || echo none)" != none ]; then
		log 'haveged not needed: rng detected'
	else
		log 'haveged needed: applying workaround for haveged-udeb (#1087324)'
		mkdir -p /dev/shm
		log 'haveged needed: starting'
		haveged
	fi
else
	log "haveged not available"
fi
