hydrophonitor/scripts/setup-rtc-2.sh

33 lines
741 B
Bash
Raw Normal View History

2022-10-22 11:41:10 +00:00
#!/bin/bash
set -x
echo "Setting up the real time clock module, part 2"
echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-3/new_device
# Load RTC clock at boot
sudo sed -i "s/^exit 0$//" /etc/rc.local
sudo cat << EOF | sudo tee -a /etc/rc.local
echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-3/new_device
sudo hwclock -s
exit 0
EOF
# Set system time to Internet time
echo "Restarting systmd-timesyncd to update system time"
sudo systemctl restart systemd-timesyncd
echo "System time now:"
date
# Write system time to the RTC module
echo "Hardware clock time now:"
2022-10-23 14:04:10 +00:00
sudo hwclock -r --verbose
2022-10-22 11:41:10 +00:00
echo "Writing system time to hardware clock"
2022-10-23 14:04:10 +00:00
sudo hwclock -w --verbose
2022-10-22 11:41:10 +00:00
echo "Hardware clock time now:"
2022-10-23 14:04:10 +00:00
sudo hwclock -r --verbose