forked from km4ack/pi-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest
66 lines (52 loc) · 1.67 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin bash
#install/configure real time clock
#20190203 km4ack
#script based on directions from the following web site
#https://thepihut.com/blogs/raspberry-pi-tutorials/17209332-adding-a-real-time-clock-to-your-raspberry-pi
clear;echo;echo
IC2ACTIVE=$(ls /dev/*i2c*)
if [ $IC2ACTIVE = "/dev/i2c-1" ]
then
echo "IC2 is active"
else
clear;echo;echo
#echo "Please enable IC2 interface in the "
#echo "Raspberry Pi Configuration and try again"
sudo sed -i 's/#dtparam=i2c_arm=on/dtparam=i2c_arm=on/' /boot/config.txt
fi
exit 0
clear;echo;echo
date
echo
read -p "Is the time above correct? y/n " ANS
if [ $ANS = 'y' ] || [ $ANS = 'Y' ]; then
echo "Time OK"
else
echo; echo "Please connect to the internet"
echo "or GPS to get correct time"; echo
exit 0
fi
sudo i2cdetect -y 1
echo;echo
read -p "Do you see 68 in the info listed above? y/n " ANS1
echo
if [ $ANS1 = 'y' ] || [ $ANS1 = 'Y' ]; then
sudo modprobe rtc-ds1307
echo "ds1307 0x68" | sudo tee -a /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -w
echo rtc-ds1307 | sudo tee -a /etc/modules
sudo sed -i 's/exit\ 0//' /etc/rc.local
echo "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "sudo hwclock -s" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "date" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "exit 0" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo
echo "The real time clock has been installed & configured"
echo "It is advised you check to make sure everything"
echo "is working correctly. See the video for instructions"
echo "Enjoy! 73, de KM4ACK"
else
echo "Please check that the real time"
echo "clock is installed correctly"
echo "and try again"
fi