#!/bin/bash
# Bit 13 of the MCU firmware features is the TRNG
features_path=/sys/bus/i2c/devices/1-002a/fw_features
[[ -r "${features_path}" ]] || exit 0
features="$(< "${features_path}")"
[[ "${features}" =~ ^0x[0-9a-fA-F]+$ ]] || exit 0
((features & 0x2000)) && exit 0
printf "\e[0;91m Warning: the MCU firmware of this Turris Omnia is outdated \x1B[0m \n"
if [[ -x /usr/sbin/omnia-mcutool ]]; then
printf "\e[0;91m Upgrade it as root with omnia-mcutool --upgrade, then reboot \x1B[0m \n"
else
printf "\e[0;91m Upgrade it with omnia-mcutool: https://gitlab.nic.cz/turris/omnia-mcutool \x1B[0m \n"
fi
