#!/bin/bash

MAXIMUM_SECONDS_BEFORE_ASSUMED_DEAD=3600
DB_FILES=`find /home/radon -name "radonEye??-??-??-??-??-??.db"`

for i in $DB_FILES; do {
  	let x=`date "+%s"`
	let x-=`stat -c "%Y" "${i}"`;
	#echo "${i} last modified ${x} seconds ago";
	test $MAXIMUM_SECONDS_BEFORE_ASSUMED_DEAD -lt $x && {
		systemctl --message "Radon tacker: rebooting because cannot connect to ${i}." reboot;
		exit;
	}
}; done;
