-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake_all.sh
More file actions
187 lines (126 loc) · 3.9 KB
/
Copy pathmake_all.sh
File metadata and controls
187 lines (126 loc) · 3.9 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
for I in iproute2 usbutils ntp ntpdate gpsd gpsd-clients wget
do
if test "`dpkg -l | grep \" $I \"`" = ""
then
echo "Installing $I..."
apt-get update
apt-get --assume-yes --quiet install $I
fi
done
if test `lsusb | grep -i U-Blox` = ""
then
echo "Cannot find USB GPS dongle. Stop here..."
exit 1
fi
F=/etc/default/gpsd
if test -e $F
then
cp $F ${F}_`date +'%s'`
cat > $F <<_EOF_
START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyACM0"
GPSD_OPTIONS="-n"
_EOF_
fi
IPV=`ip a | grep "inet "`
IPV6=`ip a | grep "inet6 "`
F=/etc/ntp.conf
if test -e $F
then
cp $F ${F}_`date +'%s'`
cat > $F <<_EOF_
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
leapfile /usr/share/zoneinfo/leap-seconds.list
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
#pool 0.de.pool.ntp.org iburst minpoll 5 maxpoll 5
#pool 1.de.pool.ntp.org iburst minpoll 5 maxpoll 5
#pool 2.de.pool.ntp.org iburst minpoll 5 maxpoll 5
#pool 3.de.pool.ntp.org iburst minpoll 5 maxpoll 5
#pool de.pool.ntp.org iburst minpoll 10 maxpoll 10
restrict source notrap nomodify noquery
restrict -4 default kod notrap nomodify nopeer noquery notrust
restrict -6 default kod notrap nomodify nopeer noquery notrust
restrict 10.0.0.0 mask 255.0.0.0 nomodify noquery
restrict 172.16.0.0 mask 255.240.0.0 nomodify noquery
restrict 169.254.0.0 mask 255.255.0.0 nomodify noquery
restrict 192.168.0.0 mask 255.255.0.0 nomodify noquery
restrict 127.0.0.0 mask 255.0.0.0 nomodify noquery
restrict 192.0.2.0 mask 255.255.255.0 ignore
restrict 192.0.0.0 mask 255.255.255.248 ignore
restrict 240.0.0.0 mask 240.0.0.0 ignore
restrict 0.0.0.0 mask 255.0.0.0 ignore
restrict 127.0.0.1
restrict ::1
broadcast 192.168.0.255 autokey ttl 3
broadcast 224.0.1.1 autokey ttl 3
broadcast 169.254.255.255 autokey ttl 3
multicastclient 224.0.1.1
disable auth
enable bclient
manycastclient 224.0.1.1
manycastserver 224.0.1.1
#see http://doc.ntp.org/4.2.6/refclock.html
server 127.127.28.0 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.0 time1 0.07 refid GPS
server 127.127.1.0 minpoll 4 maxpoll 4
fudge 127.127.1.0 stratum 12
_EOF_
echo "Check $F for network restriction. This config file has 192.168.0.0/16 set"
else
echo "Error: Cannot find $F. You need to set your values manually"
fi
F=/etc/systemd/system/sockets.target.wants/gpsd.socket
if test -e $F
then
cp $F ${F}_`date +'%s'`
cat > $F <<_EOF_
[Unit]
Description=GPS (Global Positioning System) Daemon Sockets
[Install]
WantedBy=sockets.target
[Socket]
ListenStream=/var/run/gpsd.sock
SocketMode=0600
_EOF_
if ! test "`echo $IPV`" = ""
then
echo "ListenStream=127.0.0.1:2947" >> $F
fi
if ! test "`echo $IPV6`" = ""
then
echo "ListenStream=[::1]:2947" >> $F
fi
fi
F=/usr/share/zoneinfo/leap-seconds.list
if test -e $F
then
T=`date +'%s'`
cp -f $F ${F}_$T
echo "Leap second list download"
wget https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list -O ${F}_new
if ! test -e ${F}_new
then
cp ${F}_new $F
fi
echo "Keep in mind to renew this list (/usr/share/zoneinfo/leap-seconds.list) every year..."
fi
service gpsd restart
service ntp restart
service gpsd status
service ntp status
ntpd -q
#tail -n 30 /var/log/ntp.log
timedatectl status
ntpq -c rl
# cgps
echo "Press crtl-C to stop..."
echo
echo "try watch ntpq -p "
echo
# gpds need option -n to start....