Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Last active December 13, 2020 08:50
Show Gist options
  • Save Hermann-SW/21450900fd85e9067c3d126c1e818540 to your computer and use it in GitHub Desktop.
Save Hermann-SW/21450900fd85e9067c3d126c1e818540 to your computer and use it in GitHub Desktop.
Needs to be moved to /sbin/rEboot, plays together with previous reboot gist
#!/bin/bash
if [ -f /home/pi/last_reboot ]; then
start=`date +%s`
reboot=`cat /home/pi/last_reboot`
rm /home/pi/last_reboot
# wait for NTP update
last=0
now=$last
# skip waiting in case DS3231 RTC is active via i2c-rtc dtoverlay
if [ -f /usr/sbin/i2cdetect ]; then
if [ "`i2cdetect -y 1 0x68 0x68 | grep UU`" != "" ]; then
last=$(($now-2))
fi
fi
until [ $(($now-$last)) -gt 1 ]; do
last=`date +%s`
sleep 0.5
now=`date +%s`
done
xmessage $((($start-$reboot)+($now-$last-1))) seconds for last reboot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment