S15ntp

Synopsys


#
# Enable NTP clients to use local ntp server
# Configure local ntp server
#

Script


echo "%Post: enable NTP"
# Check for an SRV record
SRV=`host -t SRV _ntp._tcp.$DOMAINNAME | grep $NODENAME\.`
# if we have a valid match we get
# FC3: SRV=_ntp._tcp.$DOMAINNAME SRV 3 0 123 $NODENAME.
# FC4: SRV=_ntp._tcp.$DOMAINNAME has SRV record 3 0 123 $NODENAME.

if [ "$OS" == "fc4" ]; then
    PRIORITY=`echo $SRV | cut -d" " -f5`
else
    PRIORITY=`echo $SRV | cut -d" " -f3`
fi

mv /etc/ntp.conf /etc/ntp.conf-$VERSION

if [ "$PRIORITY" == "4" ]; then	# NTP MASTER checking internet time
    cat >/etc/ntp.conf <<EOF
server 127.127.1.0
fudge 127.127.1.0 stratum 10
server 0.europe.pool.ntp.org
server 1.europe.pool.ntp.org
server 2.europe.pool.ntp.org
driftfile /etc/ntp/drift
authenticate no
EOF

   cat >/etc/ntp/step-tickers <<EOF
0.europe.pool.ntp.org
1.europe.pool.ntp.org
2.europe.pool.ntp.org
EOF

else 				# SLAVED to NTP master

   cat >/etc/ntp.conf <<EOF
server ntp1.$DOMAINNAME
driftfile /etc/ntp/drift
authenticate no
EOF

   cat >/etc/ntp/step-tickers <<EOF
ntp1.$DOMAINNAME
EOF

fi

chkconfig --level 345 ntpd on

Examples and Testing


# Check which peers you are connected to
# ntpq -c pe  
#
# Tell you how far down the stratum you are
# ntpq -c rv



Marked up in XHTML - ©2005 Thoughtful Solutions Ltd.