Last active
November 7, 2017 20:14
-
-
Save xyb994/333c2bab49ef31cd202045586dad1037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# real time clock | |
# ds3231 | |
# https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time | |
cd /boot/overlays | |
echo >> /boot/config.txt | |
echo 'dtoverlay=i2c-rtc,ds3231' >> /boot/config.txt | |
cp /lib/udev/hwclock-set /lib/udev/hwclock-set.old | |
sed -e '/run\/systemd\/system/,+2 s/^#*/#/' -i /lib/udev/hwclock-set | |
# disable fake-hwclock | |
# remove cronjob | |
rm /etc/cron.hourly/fake-hwclock | |
# disable and remove init script | |
update-rc.d -f fake-hwclock remove | |
rm /etc/init.d/fake-hwclock | |
# remove package | |
apt-get remove -y fake-hwclock | |
apt-get autoremove -y | |
# second autorunonce | |
mv /boot/autoranonce* /boot/autoranonce.first | |
sync | |
cat <<EOF > /boot/autorunonce | |
#!/bin/sh | |
sleep 10 | |
while ! curl -X GET https://google.com ; do | |
sleep 1 | |
done | |
sudo service ntp restart | |
sudo date > /boot/time | |
sudo hwclock -w | |
sudo hwclock -r >> /boot/time | |
sudo hwclock -s | |
sudo date >> /boot/time | |
echo "server 127.127.1.0" >> /etc/ntp.conf | |
echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf | |
echo "restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap" >> /etc/ntp.conf | |
sync;sync;sync;reboot | |
EOF | |
sync | |
sync | |
sync | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment