blob: ef8834a69f7befd45e8fea0c71e21f4019126f91 (
plain) (
blame)
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
187
188
189
190
191
192
193
194
195
196
197
198
|
#!/bin/sh
# NTP time synchronisation
#
# /src/NTP/REPOSITORY/v3/supportscripts/etc/rc,v 1.11 1993/07/09 13:17:00 kardel Exp
#
# rc,v
# Revision 1.11 1993/07/09 13:17:00 kardel
# local NTPROOT
#
# Revision 1.10 1993/07/09 11:37:29 kardel
# Initial restructured version + GPS support
#
# Revision 1.9 1993/06/23 14:10:36 kardel
# June 21st reconcilation
#
# Revision 1.7 1993/06/02 12:04:43 kardel
# May 28th reconcilation & clenaup
#
#
# non reference clock hosts will try to do an ntpdate on NTPSERVERS
#
NTPSERVERS="ntps1-0 ntps1-1 ntps2-0 ntps2-1"
NTPROOT=/local/NTP
#
# get the initial setup
#
if [ ! -r $NTPROOT/etc/setup ]; then
echo "ERROR: $NTPROOT/etc/setup missing - incorrect installation."
exit 1
else
. $NTPROOT/etc/setup
fi
umask 022 # SITE SPECIFIC: local policy - watch out for NFS and "root" rights
msg=""
#
# default configuration files are named $NTPROOT/conf/<ARCH>.<KARCH>
#
CF=$NTPROOT/conf/$ARCH.$KARCH # default configuration file
#
# Host specific config file (reference clocks) have the hostname tagged on
#
CFH="$CF"."$HOSTNAME" # specific configuration file
#
# where to find the tickadj command
#
KFIX=$NTPROOT/bin/tickadj # kernel variable fix
#
# where to find special tickadj parameters
#
TC=$NTPROOT/conf/tickconf # special tickadj parameters
#
# where to find the keys file (if not found $KEY.dumb will be used)
#
KEY=$NTPROOT/conf/ntp.keys # private key file
#
# the daemon
#
XD=$NTPROOT/bin/xntpd # NTP daemon
#
# HP adjtimed
#
ADJTIMED=$NTPROOT/bin/adjtimed # HP special (adjtime() emulation)
#
# ntpdate command
#
NTPDATE=$NTPROOT/bin/ntpdate
#
# secondary timed support
# The word "TIMED" must be in the config file for timed to start
# Note that this times is a special version which does not ever set or
# adjust the time. Ask time@informatik.uni-erlangen.de for patches
#
TIMED=$NTPROOT/bin/timed # timed (Berkeley) secondary time service
# here used in a *HARMLESS* version
# to provide time to "inferior" systems
#
# ISREFHOST is a command that returns exit status 0 for a reference host
# Site specific: sample for dcf77 is given
#
ISREFHOST="[ -f $NTPROOT/.karch.$KARCH/sys/OBJ/parsestreams.o -a -f /dev/refclock-0 ]"
#
# SETUP_REFCLOCK
#
# what to do in order to set up a local reference clock
# usually this will load a STREAMS module or initialize other things
# needed
#
SETUP_REFCLOCK() {
if modstat | grep -s 'PARSE'; then
ECHO "loadable PARSER STREAMS module already loaded."
else
ECHO "attempting to load PARSER STREAMS module..."
MDLFILE="/tmp/mdl.$$"
if modload $NTPROOT/.karch.$KARCH/sys/OBJ/parsestreams.o -o $MDLFILE 2>&1; then
modstat
else
echo WARNING: load FAILED
fi | LOG
rm -f $MDLFILE
unset MDLFILE
fi
}
kargs() {
MATCH=NO
HOSTID="`(hostid) 2>/dev/null || echo 000000`"
if [ -r "$TC" ]; then
exec 0< "$TC"
while [ "$MATCH" != "YES" ] && read HOST ID PARAM; do
if [ "$HOST" = "DEFAULT" ]; then
DEFAULT="$ID $PARAM"
else
if [ "$ID" = "$HOSTID" -o "$HOST" = "$HOSTNAME" ]; then
echo "$PARAM"
MATCH=YES
fi
fi
done
if [ "$MATCH" != "YES" ]; then
if [ -z "$DEFAULT" ]; then
echo "-A -p -s -q";
else
echo "$DEFAULT";
fi
fi
else
echo "-A -p -s -q";
fi
}
if [ -x $XD ]; then
if [ -x "$ADJTIMED" ]; then
$ADJTIMED && ECHO "adjusttimesupport: adjtimed."
fi
#
# WARNING: check ps command first, or you might kill things you don't want to
#
PID="`(ps -efa 2>/dev/null || ps auxww 2>/dev/null || echo "") | grep xntp | grep -v grep | awk '{ print $2 }'`"
if [ ! -z "$PID" ]; then
ECHO "killing old NTP daemon (PID=$PID)"
#
# enable this after checking for correctness
# kill $PID
ECHO "should do a kill $PID, if this is the right PID - check rc script"
fi
#
# try an ntpdate when timeservers are configured
#
if [ ! -z "$NTPSERVERS" -a -x $NTPDATE ]; then
ECHO "NTP initial time setting"
$NTPDATE -v $NTPSERVERS | LOG
fi
#
# look for reference clock equipment
#
if $ISREFHOST; then
ECHO "REFERENCE CLOCK SUPPORT (initializing...)"
SETUP_REFCLOCK
fi
if [ -r "$CFH" ]; then
CF="$CFH"
else
if [ ! -r "$KEY" ]; then
KEY="$KEY.dumb"
fi
fi
ECHO "NTP configuration file: $CF"
ECHO -n "time daemon startup:"
if [ -r "$CF" ]; then
if [ -x "$KFIX" ]; then
KARGS="`kargs`"
if [ ! -z "$KARGS" ]; then
$KFIX $KARGS && ECHO -n "tickadj $KARGS"
fi
fi
$XD -c "$CF" -k "$KEY" && ECHO -n ' xntpd'
if [ -x "$TIMED" ] && grep -s TIMED "$CF"; then
$TIMED -M -N && ECHO -n ' timed'
fi
else
msg="configuration file ($CF) not present."
fi
else
msg="daemon binary ($XD) not present."
fi
ECHO "."
if [ "$msg" ]; then
NLECHO "WARNING: NO NTP time sychronisation: $msg"
fi
|