Server Installation/ntpdrehash

Aus Opennet
Version vom 14. Mai 2013, 15:58 Uhr von MathiasMahnke (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Script für Gateway_Installation#NTP-Server

#!/bin/sh
#
# reconfigNtpd, written by Jan Ceuleers, March 2003, revised October 2003
#
# Purpose: ntpd running on a machine that has intermittent connectivity to
#          the Internet, and that does not have a static public IP address,
#          loses its associations with public NTP servers, even after the
#          connection to the Internet has been restored.
#          Restarting the ntpd daemon is a possibility, but the downside
#          is that this causes time not to be served to local clients until
#          ntpd has regained synchronisation.
#          A better way is to configure at least one local clock (the local
#          clock 127.127.1.0 at high stratum and/or a refclock), to cover
#          for the periods when there is no Internet connectivity, and to
#          use this script to unconfig/add{server,peer} all public time
#          servers at runtime (i.e. without restarting the daemon)
#
# Usage: reconfigNtpd | ntpdc
#
# Bugs: * This script only generates unconfig/addpeer and unconfig/addserver
#         pairs. Any relevant fudge statements or iburst options etc. are
#         ignored.
#
#       * Location of keys file is hard-coded rather than being derived from
#         ntp.conf
#

###
#
# Get keyid and password from /etc/ntp/keys
#
###
set -- $(grep "^[[:digit:]]" < /etc/ntp/keys)
echo keyid $1
echo passwd $3

###
#
# Derive unconfig commands from ntpdc output
#
###
ntpdc -n -p | awk '!/==/ && !/^ / { if (substr($1,2) !~ /^127.127./)
print "unconfig " substr($1,2) }'

###
#
# Derive addserver commands from /etc/ntp.conf
#
###
#awk '/^server[[:blank:]]/ { if ($2 !~ /^127.127./) print "addserver " $2
#}' /etc/ntp.conf

awk '/^server/ { if ($2 !~ /^127.127./) print "addserver " $2
}' /etc/ntp.conf

###
#
# Derive addpeer commands from /etc/ntp.conf
#
###
awk '/^peer[[:blank:]]/ { print "addpeer " $2 }' /etc/ntp.conf

echo quit
Meine Werkzeuge
Namensräume

Varianten
Aktionen
Start
Opennet
Kommunikation
Karten
Werkzeuge