2 # NTP time synchronisation
4 # /src/NTP/REPOSITORY/v3/supportscripts/etc/rc,v 1.11 1993/07/09 13:17:00 kardel Exp
7 # Revision 1.11 1993/07/09 13:17:00 kardel
10 # Revision 1.10 1993/07/09 11:37:29 kardel
11 # Initial restructured version + GPS support
13 # Revision 1.9 1993/06/23 14:10:36 kardel
14 # June 21st reconcilation
16 # Revision 1.7 1993/06/02 12:04:43 kardel
17 # May 28th reconcilation & clenaup
20 # non reference clock hosts will try to do an ntpdate on NTPSERVERS
22 NTPSERVERS="ntps1-0 ntps1-1 ntps2-0 ntps2-1"
26 # get the initial setup
28 if [ ! -r $NTPROOT/etc/setup ]; then
29 echo "ERROR: $NTPROOT/etc/setup missing - incorrect installation."
35 umask 022 # SITE SPECIFIC: local policy - watch out for NFS and "root" rights
39 # default configuration files are named $NTPROOT/conf/<ARCH>.<KARCH>
41 CF=$NTPROOT/conf/$ARCH.$KARCH # default configuration file
43 # Host specific config file (reference clocks) have the hostname tagged on
45 CFH="$CF"."$HOSTNAME" # specific configuration file
47 # where to find the tickadj command
49 KFIX=$NTPROOT/bin/tickadj # kernel variable fix
51 # where to find special tickadj parameters
53 TC=$NTPROOT/conf/tickconf # special tickadj parameters
55 # where to find the keys file (if not found $KEY.dumb will be used)
57 KEY=$NTPROOT/conf/ntp.keys # private key file
61 XD=$NTPROOT/bin/xntpd # NTP daemon
65 ADJTIMED=$NTPROOT/bin/adjtimed # HP special (adjtime() emulation)
69 NTPDATE=$NTPROOT/bin/ntpdate
72 # secondary timed support
73 # The word "TIMED" must be in the config file for timed to start
74 # Note that this times is a special version which does not ever set or
75 # adjust the time. Ask time@informatik.uni-erlangen.de for patches
77 TIMED=$NTPROOT/bin/timed # timed (Berkeley) secondary time service
78 # here used in a *HARMLESS* version
79 # to provide time to "inferior" systems
81 # ISREFHOST is a command that returns exit status 0 for a reference host
82 # Site specific: sample for dcf77 is given
84 ISREFHOST="[ -f $NTPROOT/.karch.$KARCH/sys/OBJ/parsestreams.o -a -f /dev/refclock-0 ]"
88 # what to do in order to set up a local reference clock
89 # usually this will load a STREAMS module or initialize other things
93 if modstat | grep -s 'PARSE'; then
94 ECHO "loadable PARSER STREAMS module already loaded."
96 ECHO "attempting to load PARSER STREAMS module..."
98 if modload $NTPROOT/.karch.$KARCH/sys/OBJ/parsestreams.o -o $MDLFILE 2>&1; then
101 echo WARNING: load FAILED
110 HOSTID="`(hostid) 2>/dev/null || echo 000000`"
111 if [ -r "$TC" ]; then
113 while [ "$MATCH" != "YES" ] && read HOST ID PARAM; do
114 if [ "$HOST" = "DEFAULT" ]; then
117 if [ "$ID" = "$HOSTID" -o "$HOST" = "$HOSTNAME" ]; then
123 if [ "$MATCH" != "YES" ]; then
124 if [ -z "$DEFAULT" ]; then
136 if [ -x "$ADJTIMED" ]; then
137 $ADJTIMED && ECHO "adjusttimesupport: adjtimed."
140 # WARNING: check ps command first, or you might kill things you don't want to
142 PID="`(ps -efa 2>/dev/null || ps auxww 2>/dev/null || echo "") | grep xntp | grep -v grep | awk '{ print $2 }'`"
144 if [ ! -z "$PID" ]; then
145 ECHO "killing old NTP daemon (PID=$PID)"
147 # enable this after checking for correctness
149 ECHO "should do a kill $PID, if this is the right PID - check rc script"
152 # try an ntpdate when timeservers are configured
154 if [ ! -z "$NTPSERVERS" -a -x $NTPDATE ]; then
155 ECHO "NTP initial time setting"
156 $NTPDATE -v $NTPSERVERS | LOG
159 # look for reference clock equipment
162 ECHO "REFERENCE CLOCK SUPPORT (initializing...)"
166 if [ -r "$CFH" ]; then
169 if [ ! -r "$KEY" ]; then
174 ECHO "NTP configuration file: $CF"
175 ECHO -n "time daemon startup:"
177 if [ -r "$CF" ]; then
178 if [ -x "$KFIX" ]; then
180 if [ ! -z "$KARGS" ]; then
181 $KFIX $KARGS && ECHO -n "tickadj $KARGS"
184 $XD -c "$CF" -k "$KEY" && ECHO -n ' xntpd'
185 if [ -x "$TIMED" ] && grep -s TIMED "$CF"; then
186 $TIMED -M -N && ECHO -n ' timed'
189 msg="configuration file ($CF) not present."
192 msg="daemon binary ($XD) not present."
197 NLECHO "WARNING: NO NTP time sychronisation: $msg"