From: Harlan Stenn Date: Sun, 22 Mar 2015 03:01:33 +0000 (+0000) Subject: [Bug 2769] New script: update-leap X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc627901ef28359ba5177fbea270dff8f9077732;p=thirdparty%2Fntp.git [Bug 2769] New script: update-leap bk: 550e308dq8pnMrB2_40r1ZogNR_yUg --- diff --git a/ChangeLog b/ChangeLog index 04fb22a9d..00f92dd0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ * [Bug 2763] Allow different thresholds for forward and backward steps. * [Bug 2766] ntp-keygen output files should not be world-readable. * [Bug 2767] ntp-keygen -M should symlink to ntp.keys. +* [Bug 2769] New script: update-leap * [Bug 2771] nonvolatile value is documented in wrong units. * [Bug 2773] Early leap announcement from Palisade/Thunderbolt * [Bug 2774] Unreasonably verbose printout - leap pending/warning diff --git a/configure.ac b/configure.ac index 11881775b..dc5c7fcfd 100644 --- a/configure.ac +++ b/configure.ac @@ -4334,20 +4334,21 @@ AC_CONFIG_FILES([ntpq/Makefile]) AC_CONFIG_FILES([ntpsnmpd/Makefile]) AC_CONFIG_FILES([parseutil/Makefile]) AC_CONFIG_FILES([scripts/Makefile]) -AC_CONFIG_FILES([scripts/lib/Makefile]) -AC_CONFIG_FILES([scripts/calc_tickadj/calc_tickadj], [chmod +x scripts/calc_tickadj/calc_tickadj]) -AC_CONFIG_FILES([scripts/calc_tickadj/Makefile]) +AC_CONFIG_FILES([scripts/build/Makefile]) AC_CONFIG_FILES([scripts/build/mkver], [chmod +x scripts/build/mkver]) -AC_CONFIG_FILES([scripts/ntp-wait/ntp-wait], [chmod +x scripts/ntp-wait/ntp-wait]) +AC_CONFIG_FILES([scripts/calc_tickadj/Makefile]) +AC_CONFIG_FILES([scripts/calc_tickadj/calc_tickadj], [chmod +x scripts/calc_tickadj/calc_tickadj]) +AC_CONFIG_FILES([scripts/lib/Makefile]) AC_CONFIG_FILES([scripts/ntp-wait/Makefile]) -AC_CONFIG_FILES([scripts/ntpsweep/ntpsweep], [chmod +x scripts/ntpsweep/ntpsweep]) +AC_CONFIG_FILES([scripts/ntp-wait/ntp-wait], [chmod +x scripts/ntp-wait/ntp-wait]) AC_CONFIG_FILES([scripts/ntpsweep/Makefile]) -AC_CONFIG_FILES([scripts/ntptrace/ntptrace], [chmod +x scripts/ntptrace/ntptrace]) +AC_CONFIG_FILES([scripts/ntpsweep/ntpsweep], [chmod +x scripts/ntpsweep/ntpsweep]) AC_CONFIG_FILES([scripts/ntptrace/Makefile]) +AC_CONFIG_FILES([scripts/ntptrace/ntptrace], [chmod +x scripts/ntptrace/ntptrace]) AC_CONFIG_FILES([scripts/ntpver], [chmod +x scripts/ntpver]) AC_CONFIG_FILES([scripts/plot_summary], [chmod +x scripts/plot_summary]) AC_CONFIG_FILES([scripts/summary], [chmod +x scripts/summary]) -AC_CONFIG_FILES([scripts/build/Makefile]) +AC_CONFIG_FILES([scripts/update-leap/Makefile]) AC_CONFIG_FILES([tests/Makefile]) AC_CONFIG_FILES([tests/libntp/Makefile]) AC_CONFIG_FILES([tests/ntpd/Makefile]) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 7ddf4247b..2664bef4d 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS= \ ntpsweep \ ntptrace \ lib \ + update-leap \ $(NULL) man1_MANS= diff --git a/scripts/update-leap/Makefile.am b/scripts/update-leap/Makefile.am new file mode 100644 index 000000000..bfcfc2cb5 --- /dev/null +++ b/scripts/update-leap/Makefile.am @@ -0,0 +1,95 @@ +NULL= +run_ag= cd $(srcdir) && env PATH="$(abs_builddir):$(PATH)" PERL5LIB="$(abs_top_srcdir)/scripts/lib" AUTOGEN_DNE_DATE=-D \ + autogen -L ../../sntp/include -L ../../sntp/ag-tpl \ + --writable +std_def_list = \ + $(top_srcdir)/sntp/include/debug-opt.def \ + $(top_srcdir)/sntp/include/autogen-version.def \ + $(top_srcdir)/sntp/include/copyright.def \ + $(top_srcdir)/sntp/include/homerc.def \ + $(top_srcdir)/sntp/include/ntp.lic \ + $(top_srcdir)/sntp/include/version.def \ + $(NULL) + +bin_SCRIPTS= $(UPDATE_LEAP_DB) +sbin_SCRIPTS= $(UPDATE_LEAP_DS) +libexec_SCRIPTS= $(UPDATE_LEAP_DL) +noinst_SCRIPTS= $(UPDATE_LEAP_NI) +EXTRA_SCRIPTS= update-leap + +man1_MANS= +man8_MANS= +if INSTALL_UPDATE_LEAP +man_MANS= update-leap.$(UPDATE_LEAP_MS) +else +noinst_MANS= update-leap.$(UPDATE_LEAP_MS) +endif + +EXTRA_DIST = \ + invoke-update-leap.menu \ + invoke-update-leap.texi \ + update-leap-opts.def \ + update-leap-opts \ + update-leap.1update-leapman \ + update-leap.1update-leapmdoc \ + update-leap.man.in \ + update-leap.mdoc.in \ + update-leap.texi \ + update-leap.html \ + $(NULL) + +html_DATA = update-leap.html + +#CLEANFILES = update-leap.1 +DISTCLEANFILES = config.log $(man_MANS) $(noinst_MANS) + +noinst_DATA = \ + invoke-update-leap.menu \ + invoke-update-leap.texi \ + update-leap.man.in \ + update-leap.mdoc.in \ + update-leap-opts \ + $(NULL) + +update-leap: $(srcdir)/update-leap-opts + +$(srcdir)/update-leap-opts: update-leap-opts.def $(std_def_list) + $(run_ag) update-leap-opts.def + +### Man + +$(srcdir)/update-leap.1update-leapman: $(srcdir)/update-leap-opts.def $(std_def_list) + $(run_ag) -DMAN_SECTION=1update-leapman -Tagman-cmd.tpl update-leap-opts.def + +$(srcdir)/update-leap.man.in: $(srcdir)/update-leap.1update-leapman $(top_srcdir)/sntp/scripts/mansec2subst.sed + sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/update-leap.1update-leapman > $(srcdir)/update-leap.man.in+ + mv $(srcdir)/update-leap.man.in+ $(srcdir)/update-leap.man.in + +### Mdoc + +$(srcdir)/update-leap.1update-leapmdoc: $(srcdir)/update-leap-opts.def $(std_def_list) + $(run_ag) -DMAN_SECTION=1update-leapmdoc -Tagmdoc-cmd.tpl update-leap-opts.def + +$(srcdir)/update-leap.mdoc.in: $(srcdir)/update-leap.1update-leapmdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed + sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/update-leap.1update-leapmdoc > $(srcdir)/update-leap.mdoc.in+ + mv $(srcdir)/update-leap.mdoc.in+ $(srcdir)/update-leap.mdoc.in + +### Manpage + +update-leap.$(UPDATE_LEAP_MS): $(srcdir)/update-leap.$(MANTAGFMT).in $(top_builddir)/config.status + $(top_builddir)/config.status --file=update-leap.$(UPDATE_LEAP_MS)+:$(srcdir)/update-leap.$(MANTAGFMT).in + mv update-leap.$(UPDATE_LEAP_MS)+ update-leap.$(UPDATE_LEAP_MS) + +### Texinfo + +$(srcdir)/invoke-update-leap.menu: $(srcdir)/invoke-update-leap.texi + @: do-nothing action to avoid default SCCS get, .menu built with .texi + +$(srcdir)/invoke-update-leap.texi: $(srcdir)/update-leap-opts.def $(std_def_list) + $(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section update-leap-opts.def + $(top_srcdir)/scripts/build/check--help $@ + +### HTML + +$(srcdir)/update-leap.html: $(srcdir)/update-leap.texi $(top_srcdir)/sntp/include/version.texi + cd $(srcdir) && ( makeinfo --force --html --no-split -I ../sntp -o update-leap.html update-leap.texi || true ) diff --git a/scripts/update-leap/invoke-update-leap.menu b/scripts/update-leap/invoke-update-leap.menu new file mode 100644 index 000000000..e27e34925 --- /dev/null +++ b/scripts/update-leap/invoke-update-leap.menu @@ -0,0 +1 @@ +* update-leap Invocation:: Invoking update-leap diff --git a/scripts/update-leap/invoke-update-leap.texi b/scripts/update-leap/invoke-update-leap.texi new file mode 100644 index 000000000..f85978efa --- /dev/null +++ b/scripts/update-leap/invoke-update-leap.texi @@ -0,0 +1,169 @@ +@node update-leap Invocation +@section Invoking update-leap +@pindex update-leap +@cindex leap-seconds file manager/updater +@ignore +# +# EDIT THIS FILE WITH CAUTION (invoke-update-leap.texi) +# +# It has been AutoGen-ed March 22, 2015 at 01:38:19 AM by AutoGen 5.18.5pre6 +# From the definitions update-leap-opts.def +# and the template file agtexi-cmd.tpl +@end ignore + + + +@code{update-leap} +will validate the file currently on the local syste +and if necessary, updates leap-second definition file. + +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. + +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. + +If the current file is acceptable, no download or restart occurs. + +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS + +This section was generated by @strong{AutoGen}, +using the @code{agtexi-cmd} template and the option descriptions for the @code{update-leap} program. + +@menu +* update-leap usage:: update-leap help/usage (@option{--help}) +* update-leap source-url:: source-url option (-s) +* update-leap ipv4:: ipv4 option (-4) +* update-leap destination:: destination option (-d) +* update-leap expiration:: expiration option (-e) +* update-leap ntp-conf-file:: ntp-conf-file option (-f) +* update-leap force-update:: force-update option (-F) +* update-leap exit status:: exit status +* update-leap Usage:: Usage +* update-leap Authors:: Authors +@end menu + +@node update-leap usage +@subsection update-leap help/usage (@option{--help}) +@cindex update-leap help + +This is the automatically generated usage text for update-leap. + +The text printed is the same whether selected with the @code{help} option +(@option{--help}) or the @code{more-help} option (@option{--more-help}). @code{more-help} will print +the usage text by passing it through a pager program. +@code{more-help} is disabled on platforms without a working +@code{fork(2)} function. The @code{PAGER} environment variable is +used to select the program, defaulting to @file{more}. Both will exit +with a status code of 0. + +@exampleindent 0 +@example +/bin/bash: line 135: ./update-leap: Permission denied +@end example +@exampleindent 4 + +@node update-leap source-url +@subsection source-url option (-s) +@cindex update-leap-source-url + +This is the ``the url of the master copy of the leapseconds file'' option. +This option takes a string argument. +Specify the URL of the master copy to download +$LEAPSRC +@node update-leap ipv4 +@subsection ipv4 option (-4) +@cindex update-leap-ipv4 + +This is the ``use only ipv4 addresses for dns name resolution'' option. + +@noindent +This option has some usage constraints. It: +@itemize @bullet +@item +must not appear in combination with any of the following options: +ipv6. +@end itemize + + Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +}; + +flag = { + name = ipv6; + flags-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +}; + +flag = { + name = prefer; + flags-cant = ipv4, ipv6; + value = p; + arg-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<- _EndOfDoc_ +Prefer IPv4 or IPv6 (as specified) addresses, but use either. +@node update-leap destination +@subsection destination option (-d) +@cindex update-leap-destination + +This is the ``filename on the local system'' option. +This option takes a string argument @file{float}. +The name to use to store the leapfile on the local system. +$LEAPFILE +@node update-leap expiration +@subsection expiration option (-e) +@cindex update-leap-expiration + +This is the ``refresh the leapfile this long before it expires'' option. +This option takes a string argument. +Specify how long before expiration the file is to be refreshed +Units are required, e.g. "-e 60 days" Note that larger values +imply more frequent refreshes. +"$PREFETCH" +@node update-leap ntp-conf-file +@subsection ntp-conf-file option (-f) +@cindex update-leap-ntp-conf-file + +This is the ``location of the ntp.conf file'' option. +This option takes a string argument. +Specify location of ntp.conf (used to make sure leapfile directive is +present and to default leapfile) +$NTPCONF +@node update-leap force-update +@subsection force-update option (-F) +@cindex update-leap-force-update + +This is the ``force update of the leapfile'' option. +Force update even if current file is OK and not close to expiring. +@node update-leap exit status +@subsection update-leap exit status + +One of the following exit values will be returned: +@table @samp +@item 0 (EXIT_SUCCESS) +Successful program execution. +@item 1 (EXIT_FAILURE) +The operation failed or the command syntax was not valid. +@end table +@node update-leap Usage +@subsection update-leap Usage +@node update-leap Authors +@subsection update-leap Authors diff --git a/scripts/update-leap/update-leap b/scripts/update-leap/update-leap new file mode 100644 index 000000000..2dab4eca3 --- /dev/null +++ b/scripts/update-leap/update-leap @@ -0,0 +1,434 @@ +#!/bin/bash + +# Copyright (C) 2014 Timothe Litt litt at acm dot org + +# This script may be freely copied, used and modified providing that +# this notice and the copyright statement are included in all copies +# and derivative works. No warranty is offered, and use is entirely at +# your own risk. Bugfixes and improvements would be appreciated by the +# author. + +VERSION="1.003" + +# leap-seconds file manager/updater + +# Depends on: +# wget sed, tr, shasum, logger + +# ########## Default configuration ########## +# +# Where to get the file +LEAPSRC="ftp://time.nist.gov/pub/leap-seconds.list" + +# How many times to try to download new file +MAXTRIES=6 +INTERVAL=10 + +# Where to find ntp config file +NTPCONF=/etc/ntp.conf + +# How long before expiration to get updated file +PREFETCH="60 days" + +# How to restart NTP - older NTP: service ntpd? try-restart | condrestart +# Recent NTP checks for new file daily, so there's nothing to do +RESTART= + +# Where to put temporary copy before it's validated +TMPFILE="/tmp/leap-seconds.$$.tmp" + +# Syslog facility +LOGFAC=daemon +# ########################################### + +# Places to look for commands. Allows for CRON having path to +# old utilities on embedded systems + +PATHLIST="/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" + +REQUIREDCMDS=" wget logger tr sed shasum" + +SELF="`basename $0`" + +function displayHelp { + cat < - ntpd checks file daily + -r Specify number of times to retry on get failure + $MAXTRIES + -i Specify number of minutes between retries + $INTERVAL + -l Use syslog for output (Implied if CRONJOB is set) + -L Don't use syslog for output + -P Specify the syslog facility for logging + $LOGFAC + -t Name of temporary file used in validation + $TMPFILE + -q Only report errors to stdout + -v Verbose output + -z Specify path for utilities + $PATHLIST + -Z Only use system path + +$SELF will validate the file currently on the local system + +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. + +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. + +If the current file is acceptable, no download or restart occurs. + +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. + +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. + +For cron-friendly behavior, define CRONJOB=1 in the crontab. + +This script depends on$REQUIREDCMDS + +Version $VERSION +EOF + return 0 +} + +# Default: Use syslog for logging if running under cron + +SYSLOG="$CRONJOB" + +if [ "$1" = "--help" ]; then + displayHelp + exit 0 +fi + +# Parse options + +while getopts 46p:P:s:e:f:Fc:r:i:lLt:hqvz:Z opt; do + case $opt in + 4) + PROTO="-4" + ;; + 6) + PROTO="-6" + ;; + p) + if [ "$OPTARG" = '4' -o "$OPTARG" = '6' ]; then + PREFER="--prefer-family=IPv$OPTARG" + else + echo "Invalid -p $OPTARG" >&2 + exit 1; + fi + ;; + P) + LOGFAC="$OPTARG" + ;; + s) + LEAPSRC="$OPTARG" + ;; + e) + PREFETCH="$OPTARG" + ;; + f) + NTPCONF="$OPTARG" + ;; + F) + FORCE="Y" + ;; + c) + RESTART="$OPTARG" + ;; + r) + MAXTRIES="$OPTARG" + ;; + i) + INTERVAL="$OPTARG" + ;; + t) + TMPFILE="$OPTARG" + ;; + l) + SYSLOG="y" + ;; + L) + SYSLOG= + ;; + h) + displayHelp + exit 0 + ;; + q) + QUIET="Y" + ;; + v) + VERBOSE="Y" + ;; + z) + PATHLIST="$OPTARG:" + ;; + Z) + PATHLIST= + ;; + *) + echo "$SELF -h for usage" >&2 + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +export PATH="$PATHLIST$PATH" + +# Add to path to deal with embedded systems +# +for P in $REQUIREDCMDS ; do + if >/dev/null 2>&1 which "$P" ; then + continue + fi + [ "$P" = "logger" ] && continue + echo "FATAL: missing $P command, please install" + exit 1 +done + +# Handle logging + +if ! LOGGER="`2>/dev/null which logger`" ; then + LOGGER= +fi + +function log { + # "priority" "message" + # + # Stdout unless syslog specified or logger isn't available + # + if [ -z "$SYSLOG" -o -z "$LOGGER" ]; then + if [ -n "$QUIET" -a \( "$1" = "info" -o "$1" = "notice" -o "$1" = "debug" \) ]; then + return 0 + fi + echo "`echo \"$1\" | tr a-z A-Z`: $2" + return 0 + fi + + # Also log to stdout if cron job && notice or higher + local S + if [ -n "$CRONJOB" -a \( "$1" != "info" \) -a \( "$1" != "debug" \) ] || [ -n "$VERBOSE" ]; then + S="-s" + fi + $LOGGER $S -t "$SELF[$$]" -p "$LOGFAC.$1" "$2" +} + +# Verify interval +INTERVAL=$(( $INTERVAL *1 )) + +# Validate a leap-seconds file checksum +# +# File format: (full description in files) +# # marks comments, except: +# #$ number : the NTP date of the last update +# #@ number : the NTP date that the file expires +# Date (seconds since 1900) leaps : leaps is the # of seconds to add for times >= Date +# Date lines have comments. +# #h hex hex hex hex hex is the SHA-1 checksum of the data & dates, excluding whitespace w/o leading zeroes + +function verifySHA { + + if [ ! -f "$1" ]; then + return 1 + fi + + # Remove comments, except those that are markers for last update, expires and hash + + local RAW="`sed $1 -e'/^\\([0-9]\\|#[\$@h]\)/!d' -e'/^#[\$@h]/!s/#.*\$//g'`" + + # Extract just the data, removing all whitespace + + local DATA="`echo \"$RAW\" | sed -e'/^#h/d' -e's/^#[\$@]//g' | tr -d '[:space:]'`" + + # Compute the SHA hash of the data, removing the marker and filename + # Computed in binary mode, which shouldn't matter since whitespace has been removed + # shasum comes in several flavors; a portable one is available in Perl (with Digest::SHA) + + local DSHA="`echo -n \"$DATA\" | shasum | sed -e's/[? *].*$//'`" + + # Extract the file's hash. Restore any leading zeroes in hash segments. + + # The sed [] includes a tab (\t) and space; #h is followed by a tab and space + local FSHA="`echo \"$RAW\" | sed -e'/^#h/!d' -e's/^#h//' -e's/[ ] */ 0x/g'`" + FSHA=`printf '%08x%08x%08x%08x%08x' $FSHA` + + if [ -n "$FSHA" -a \( "$FSHA" = "$DSHA" \) ]; then + if [ -n "$2" ]; then + log "info" "Checksum of $1 validated" + fi + else + log "error" "Checksum of $1 is invalid:" + [ -z "$FSHA" ] && FSHA="(no checksum record found in file)" + log "error" "EXPECTED: $FSHA" + log "error" "COMPUTED: $DSHA" + return 1 + fi + + # Check the expiration date, converting NTP epoch to Unix epoch used by date + + EXPIRES="`echo \"$RAW\" | sed -e'/^#@/!d' -e's/^#@//' | tr -d '[:space:]'`" + EXPIRES="$(($EXPIRES - 2208988800 ))" + + if [ $EXPIRES -lt `date -u +%s` ]; then + log "notice" "File expired on `date -u -d \"Jan 1, 1970 00:00:00 +0000 + $EXPIRES seconds\"`" + return 2 + fi + +} + +# Verify ntp.conf + +if ! [ -f "$NTPCONF" ]; then + log "critical" "Missing ntp configuration $NTPCONF" + exit 1 +fi + +# Parse ntp.conf for leapfile directive + +LEAPFILE="`sed $NTPCONF -e'/^ *leapfile *.*$/!d' -e's/^ *leapfile *//'`" +if [ -z "$LEAPFILE" ]; then + log "error" "$NTPCONF does not specify a leapfile" +fi + +# Allow placing the file someplace else - testing + +if [ -n "$1" ]; then + if [ "$1" != "$LEAPFILE" ]; then + log "notice" "Requested install to $1, but $NTPCONF specifies $LEAPFILE" + fi + LEAPFILE="$1" +fi + +# Verify the current file +# If it is missing, doesn't validate or expired +# Or is expiring soon +# Download a new one + +if [ -n "$FORCE" ] || ! verifySHA $LEAPFILE "$VERBOSE" || [ $EXPIRES -lt `date -d "NOW + $PREFETCH" +%s` ] ; then + TRY=0 + while true; do + TRY=$(( $TRY + 1 )) + if [ -n "$VERBOSE" ]; then + log "info" "Attempting download from $LEAPSRC, try $TRY.." + fi + if wget $PROTO $PREFER -o ${TMPFILE}.log $LEAPSRC -O $TMPFILE ; then + log "info" "Download of $LEAPSRC succeeded" + if [ -n "$VERBOSE" ]; then + cat ${TMPFILE}.log + fi + + if ! verifySHA $TMPFILE "$VERBOSE" ; then + # There is no point in retrying, as the file on the server is almost + # certainly corrupt. + + log "warning" "Downloaded file $TMPFILE rejected -- saved for diagnosis" + cat ${TMPFILE}.log + rm -f ${TMPFILE}.log + exit 1 + fi + rm -f ${TMPFILE}.log + + # Set correct permissions on temporary file + + REFFILE="$LEAPFILE" + if [ ! -f $LEAPFILE ]; then + log "notice" "$LEAPFILE was missing, creating new copy - check permissions" + touch $LEAPFILE + # Can't copy permissions from old file, copy from NTPCONF instead + REFFILE="$NTPCONF" + fi + chmod --reference $REFFILE $TMPFILE + chown --reference $REFFILE $TMPFILE + ( which selinuxenabled && selinuxenabled && which chcon ) >/dev/null 2>&1 + if [ $? == 0 ] ; then + chcon --reference $REFFILE $TMPFILE + fi + + # Replace current file with validated new one + + if mv -f $TMPFILE $LEAPFILE ; then + log "notice" "Installed new $LEAPFILE from $LEAPSRC" + else + log "error" "Install $TMPFILE => $LEAPFILE failed -- saved for diagnosis" + exit 1 + fi + + # Restart NTP (or whatever else is specified) + + if [ -n "$RESTART" ]; then + if [ -n "$VERBOSE" ]; then + log "info" "Attempting restart action: $RESTART" + fi + R="$( 2>&1 $RESTART )" + if [ $? -eq 0 ]; then + log "notice" "Restart action succeeded" + if [ -n "$VERBOSE" -a -n "$R" ]; then + log "info" "$R" + fi + else + log "error" "Restart action failed" + if [ -n "$R" ]; then + log "error" "$R" + fi + exit 2 + fi + fi + exit 0 + fi + + # Failed to download. See about trying again + + rm -f $TMPFILE + if [ $TRY -ge $MAXTRIES ]; then + break; + fi + if [ -n "$VERBOSE" ]; then + cat ${TMPFILE}.log + log "info" "Waiting $INTERVAL minutes before retrying..." + fi + sleep $(( $INTERVAL * 60)) + done + + # Failed and out of retries + + log "warning" "Download from $LEAPSRC failed after $TRY attempts" + if [ -f ${TMPFILE}.log ]; then + cat ${TMPFILE}.log + rm -f ${TMPFILE}.log $TMPFILE + fi + exit 1 +fi +log "info" "Not time to replace $LEAPFILE" + +exit 0 + +# EOF \ No newline at end of file diff --git a/scripts/update-leap/update-leap-opts b/scripts/update-leap/update-leap-opts new file mode 100644 index 000000000..79beb08a4 --- /dev/null +++ b/scripts/update-leap/update-leap-opts @@ -0,0 +1,72 @@ +# EDIT THIS FILE WITH CAUTION (update-leap-opts) +# +# It has been AutoGen-ed March 22, 2015 at 01:21:23 AM by AutoGen 5.18.5pre6 +# From the definitions update-leap-opts.def +# and the template file perlopt + +use Getopt::Long qw(GetOptionsFromArray); +Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always)); + +my $usage; + +sub usage { + my ($ret) = @_; + print STDERR $usage; + exit $ret; +} + +sub paged_usage { + my ($ret) = @_; + my $pager = $ENV{PAGER} || '(less || more)'; + + open STDOUT, "| $pager" or die "Can't fork a pager: $!"; + print $usage; + + exit $ret; +} + +sub processOptions { + my $args = shift; + + my $opts = { + 'source-url' => '', + 'ipv4' => '', + 'destination' => '', + 'expiration' => '', + 'ntp-conf-file' => '', + 'force-update' => '', + 'dont-wait' => '', + 'help' => '', 'more-help' => '' + }; + my $argument = ''; + my $ret = GetOptionsFromArray($args, $opts, ( + 'source-url|s=s', 'ipv4|4', 'destination|d=f', + 'expiration|e=s', 'ntp-conf-file|f=s', 'force-update|F', + 'dont-wait', + 'help|?', 'more-help')); + + $usage = <<'USAGE'; +update-leap - leap-seconds file manager/updater - Ver. 4.2.8p1 +USAGE: update-leap [ - [] | --[{=| }] ]... + + -s, --source-url=str The URL of the master copy of the leapseconds file + -4, --ipv4 Use only IPv4 addresses for DNS name resolution + -d, --destination=float Filename on the local system + -e, --expiration=str Refresh the leapfile this long before it expires + -f, --ntp-conf-file=str Location of the ntp.conf file + -F, --force-update Force update of the leapfile + --dont-wait Don't wait for keystroke between plots + -?, --help Display usage information and exit + --more-help Pass the extended usage text through a pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +USAGE + + usage(0) if $opts->{'help'}; + paged_usage(0) if $opts->{'more-help'}; + $_[0] = $opts; + return $ret; +} + +END { close STDOUT }; diff --git a/scripts/update-leap/update-leap-opts.def b/scripts/update-leap/update-leap-opts.def new file mode 100644 index 000000000..2f90d1f91 --- /dev/null +++ b/scripts/update-leap/update-leap-opts.def @@ -0,0 +1,162 @@ +/* -*- Mode: Text -*- */ +autogen definitions perlopt; + +#include autogen-version.def + +prog-name = 'update-leap'; +prog-title = 'leap-seconds file manager/updater'; +package = ntp; +#include version.def + +long-opts; +gnu-usage; + +flag = { + name = source-url; + value = s; + arg-type = string; + descrip = 'The URL of the master copy of the leapseconds file'; + doc = <<- _EndOfDoc_ + Specify the URL of the master copy to download + $LEAPSRC + _EndOfDoc_; +}; +flag = { + name = ipv4; + flags-cant = ipv6; + value = 4; + descrip = "Use only IPv4 addresses for DNS name resolution"; + doc = <<- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +}; + +flag = { + name = ipv6; + flags-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +}; + +flag = { + name = prefer; + flags-cant = ipv4, ipv6; + value = p; + arg-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<- _EndOfDoc_ + Prefer IPv4 or IPv6 (as specified) addresses, but use either. + _EndOfDoc_; +}; + +flag = { + name = destination; + value = d; + arg-type = string; + arg-name = float; + descrip = 'Filename on the local system'; + doc = <<- _EndOfDoc_ + The name to use to store the leapfile on the local system. + $LEAPFILE + _EndOfDoc_; +}; + +flag = { + name = expiration; + value = e; + arg-type = string; + descrip = 'Refresh the leapfile this long before it expires'; + doc = <<- _EndOfDoc_ + Specify how long before expiration the file is to be refreshed + Units are required, e.g. "-e 60 days" Note that larger values + imply more frequent refreshes. + "$PREFETCH" + _EndOfDoc_; +}; + +flag = { + name = ntp-conf-file; + value = f; + arg-type = string; + descrip = 'Location of the ntp.conf file'; + doc = <<- _EndOfDoc_ + Specify location of ntp.conf (used to make sure leapfile directive is + present and to default leapfile) + $NTPCONF + _EndOfDoc_; +}; + +flag = { + name = force-update; + value = F; + descrip = 'Force update of the leapfile'; + doc = <<- _EndOfDoc_ + Force update even if current file is OK and not close to expiring. + _EndOfDoc_; +}; + +flag = { + name = dont-wait; + descrip = "Don't wait for keystroke between plots"; + doc = <<- _EndOfDoc_ + _EndOfDoc_; +}; + +/* explain: Additional information whenever the usage routine is invoked */ +explain = <<- _END_EXPLAIN + _END_EXPLAIN; + +doc-section = { + ds-type = 'DESCRIPTION'; + ds-format = 'mdoc'; + ds-text = <<- _END_PROG_MDOC_DESCRIP +.Nm +will validate the file currently on the local syste +and if necessary, updates leap-second definition file. +.Pp +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. +.Pp +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. +.Pp +If the current file is acceptable, no download or restart occurs. +.Pp +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS + _END_PROG_MDOC_DESCRIP; +}; + + +doc-section = { + ds-type = 'USAGE'; + ds-format = 'mdoc'; + ds-text = <<- _END_MDOC_USAGE + +Usage stuff + + _END_MDOC_USAGE; +}; + +doc-section = { + ds-type = 'AUTHORS'; + ds-format = 'mdoc'; + ds-text = <<- _END_MDOC_AUTHORS +.An "Timothe Litt" + _END_MDOC_AUTHORS; +}; diff --git a/scripts/update-leap/update-leap.1update-leapman b/scripts/update-leap/update-leap.1update-leapman new file mode 100644 index 000000000..7fc7838d6 --- /dev/null +++ b/scripts/update-leap/update-leap.1update-leapman @@ -0,0 +1,168 @@ +.de1 NOP +. it 1 an-trap +. if \\n[.$] \,\\$*\/ +.. +.ie t \ +.ds B-Font [CB] +.ds I-Font [CI] +.ds R-Font [CR] +.el \ +.ds B-Font B +.ds I-Font I +.ds R-Font R +.TH update-leap 1update-leapman "22 Mar 2015" "ntp (4.2.8p1)" "User Commands" +.\" +.\" EDIT THIS FILE WITH CAUTION (in-mem file) +.\" +.\" It has been AutoGen-ed March 22, 2015 at 01:38:24 AM by AutoGen 5.18.5pre6 +.\" From the definitions update-leap-opts.def +.\" and the template file agman-cmd.tpl +.SH NAME +\f\*[B-Font]update-leap\fP +\- leap-seconds file manager/updater +.SH SYNOPSIS +\f\*[B-Font]update-leap\fP +.\" Mixture of short (flag) options and long options +[\f\*[B-Font]\-flags\f[]] +[\f\*[B-Font]\-flag\f[] [\f\*[I-Font]value\f[]]] +[\f\*[B-Font]\-\-option-name\f[][[=| ]\f\*[I-Font]value\f[]]] +.sp \n(Ppu +.ne 2 + +All arguments must be options. +.sp \n(Ppu +.ne 2 + +.SH DESCRIPTION +\f\*[B-Font]update-leap\fP +will validate the file currently on the local syste +and if necessary, updates leap-second definition file. +.sp \n(Ppu +.ne 2 + +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. +.sp \n(Ppu +.ne 2 + +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. +.sp \n(Ppu +.ne 2 + +If the current file is acceptable, no download or restart occurs. +.sp \n(Ppu +.ne 2 + +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS +.SH "OPTIONS" +.TP +.NOP \f\*[B-Font]\-s\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-source\-url\f[]=\f\*[I-Font]string\f[] +The URL of the master copy of the leapseconds file. +.sp +Specify the URL of the master copy to download +$LEAPSRC +.TP +.NOP \f\*[B-Font]\-4\f[], \f\*[B-Font]\-\-ipv4\f[] +Use only IPv4 addresses for DNS name resolution. +This option must not appear in combination with any of the following options: +ipv6. +.sp + Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = ipv6; + flags-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = prefer; + flags-cant = ipv4, ipv6; + value = p; + arg-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<- _EndOfDoc_ +Prefer IPv4 or IPv6 (as specified) addresses, but use either. +.TP +.NOP \f\*[B-Font]\-d\f[] \f\*[I-Font]float\f[], \f\*[B-Font]\-\-destination\f[]=\f\*[I-Font]float\f[] +Filename on the local system. +.sp +The name to use to store the leapfile on the local system. +$LEAPFILE +.TP +.NOP \f\*[B-Font]\-e\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-expiration\f[]=\f\*[I-Font]string\f[] +Refresh the leapfile this long before it expires. +.sp +Specify how long before expiration the file is to be refreshed +Units are required, e.g. "-e 60 days" Note that larger values +imply more frequent refreshes. +"$PREFETCH" +.TP +.NOP \f\*[B-Font]\-f\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-ntp\-conf\-file\f[]=\f\*[I-Font]string\f[] +Location of the ntp.conf file. +.sp +Specify location of ntp.conf (used to make sure leapfile directive is +present and to default leapfile) +$NTPCONF +.TP +.NOP \f\*[B-Font]\-F\f[], \f\*[B-Font]\-\-force\-update\f[] +Force update of the leapfile. +.sp +Force update even if current file is OK and not close to expiring. +.TP +.NOP \f\*[B-Font]\-\-dont\-wait\f[] +Don't wait for keystroke between plots. +.sp +.TP +.NOP \f\*[B-Font]\-\&?\f[], \f\*[B-Font]\-\-help\f[] +Display usage information and exit. +.TP +.NOP \f\*[B-Font]\-\&!\f[], \f\*[B-Font]\-\-more-help\f[] +Pass the extended usage information through a pager. +.TP +.NOP \f\*[B-Font]\-v\f[] [{\f\*[I-Font]v|c|n\f[] \f\*[B-Font]\-\-version\f[] [{\f\*[I-Font]v|c|n\f[]}]}] +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.PP +.SH USAGE +Usage stuff +.SH "EXIT STATUS" +One of the following exit values will be returned: +.TP +.NOP 0 " (EXIT_SUCCESS)" +Successful program execution. +.TP +.NOP 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.TP +.NOP 70 " (EX_SOFTWARE)" +libopts had an internal operational error. Please report +it to autogen-users@lists.sourceforge.net. Thank you. +.PP +.SH AUTHORS +.NOP "Timothe Litt" +.br +.SH "NOTES" +This manual page was \fIAutoGen\fP-erated from the \fBupdate-leap\fP +option definitions. diff --git a/scripts/update-leap/update-leap.1update-leapmdoc b/scripts/update-leap/update-leap.1update-leapmdoc new file mode 100644 index 000000000..e03921e9e --- /dev/null +++ b/scripts/update-leap/update-leap.1update-leapmdoc @@ -0,0 +1,133 @@ +.Dd March 22 2015 +.Dt UPDATE_LEAP 1update-leapmdoc User Commands +.Os +.\" EDIT THIS FILE WITH CAUTION (update-leap-opts.mdoc) +.\" +.\" It has been AutoGen-ed March 22, 2015 at 01:21:23 AM by AutoGen 5.18.5pre6 +.\" From the definitions update-leap-opts.def +.\" and the template file agmdoc-cmd.tpl +.Sh NAME +.Nm update-leap +.Nd leap-seconds file manager/updater +.Sh SYNOPSIS +.Nm +.\" Mixture of short (flag) options and long options +.Op Fl flags +.Op Fl flag Op Ar value +.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc +.Pp +All arguments must be options. +.Pp +.Sh DESCRIPTION +.Nm +will validate the file currently on the local syste +and if necessary, updates leap\-second definition file. +.Pp +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. +.Pp +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. +.Pp +If the current file is acceptable, no download or restart occurs. +.Pp +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron\-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS +.Sh "OPTIONS" +.Bl -tag +.It Fl s Ar string , Fl \-source\-url Ns = Ns Ar string +The URL of the master copy of the leapseconds file. +.sp +Specify the URL of the master copy to download +$LEAPSRC +.It Fl 4 , Fl \-ipv4 +Use only IPv4 addresses for DNS name resolution. +This option must not appear in combination with any of the following options: +ipv6. +.sp + Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = ipv6; + flags\-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<\- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = prefer; + flags\-cant = ipv4, ipv6; + value = p; + arg\-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<\- _EndOfDoc_ +Prefer IPv4 or IPv6 (as specified) addresses, but use either. +.It Fl d Ar float , Fl \-destination Ns = Ns Ar float +Filename on the local system. +.sp +The name to use to store the leapfile on the local system. +$LEAPFILE +.It Fl e Ar string , Fl \-expiration Ns = Ns Ar string +Refresh the leapfile this long before it expires. +.sp +Specify how long before expiration the file is to be refreshed +Units are required, e.g. "\-e 60 days" Note that larger values +imply more frequent refreshes. +"$PREFETCH" +.It Fl f Ar string , Fl \-ntp\-conf\-file Ns = Ns Ar string +Location of the ntp.conf file. +.sp +Specify location of ntp.conf (used to make sure leapfile directive is +present and to default leapfile) +$NTPCONF +.It Fl F , Fl \-force\-update +Force update of the leapfile. +.sp +Force update even if current file is OK and not close to expiring. +.It Fl \-dont\-wait +Don't wait for keystroke between plots. +.sp +.It Fl \&? , Fl \-help +Display usage information and exit. +.It Fl \&! , Fl \-more\-help +Pass the extended usage information through a pager. +.It Fl v Op Brq Ar v|c|n Fl \-version Op Brq Ar v|c|n +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.El +.Sh USAGE +Usage stuff +.Sh "EXIT STATUS" +One of the following exit values will be returned: +.Bl -tag +.It 0 " (EXIT_SUCCESS)" +Successful program execution. +.It 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.It 70 " (EX_SOFTWARE)" +libopts had an internal operational error. Please report +it to autogen\-users@lists.sourceforge.net. Thank you. +.El +.Sh AUTHORS +.An "Timothe Litt" +.Sh "NOTES" +This manual page was \fIAutoGen\fP\-erated from the \fBupdate\-leap\fP +option definitions. diff --git a/scripts/update-leap/update-leap.html b/scripts/update-leap/update-leap.html new file mode 100644 index 000000000..e0b876abd --- /dev/null +++ b/scripts/update-leap/update-leap.html @@ -0,0 +1,297 @@ + + +update-leap User's Manual + + + + + + + + + +

update-leap User's Manual

+
+ +


+Next: , +Previous: (dir), +Up: (dir) + +
+ +

This document describes the use of the NTP Project's update-leap program. + +

This document applies to version 4.2.8p1 of update-leap. + +

+

Short Contents

+
    +
+
+ + + +
+ + +


+ + +
+ +

0.1 Invoking update-leap

+ +

+ +

update-leap +will validate the file currently on the local syste +and if necessary, updates leap-second definition file. + +

Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. + +

If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. + +

If the current file is acceptable, no download or restart occurs. + +

-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS + +

This section was generated by AutoGen, +using the agtexi-cmd template and the option descriptions for the update-leap program. + +

+ + + +

0.1.1 update-leap help/usage (--help)

+ +

+This is the automatically generated usage text for update-leap. + +

The text printed is the same whether selected with the help option +(--help) or the more-help option (--more-help). more-help will print +the usage text by passing it through a pager program. +more-help is disabled on platforms without a working +fork(2) function. The PAGER environment variable is +used to select the program, defaulting to more. Both will exit +with a status code of 0. + +

/bin/bash: line 135: ./update-leap: Permission denied
+
+
+ + +


+Next: , +Previous: update-leap usage, +Up: update-leap Invocation + +
+ +

0.1.2 source-url option (-s)

+ +

+This is the “the url of the master copy of the leapseconds file” option. +This option takes a string argument. +Specify the URL of the master copy to download +$LEAPSRC +

+ +

0.1.3 ipv4 option (-4)

+ +

+This is the “use only ipv4 addresses for dns name resolution” option. + +

This option has some usage constraints. It: +

    +
  • must not appear in combination with any of the following options: +ipv6. +
+ +

Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +; + +

flag = + name = ipv6; + flags-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +; + +

flag = + name = prefer; + flags-cant = ipv4, ipv6; + value = p; + arg-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<- _EndOfDoc_ +Prefer IPv4 or IPv6 (as specified) addresses, but use either. +

+ + +


+Next: , +Previous: update-leap ipv4, +Up: update-leap Invocation + +
+ +

0.1.4 destination option (-d)

+ +

+This is the “filename on the local system” option. +This option takes a string argument float. +The name to use to store the leapfile on the local system. +$LEAPFILE +

+ +

0.1.5 expiration option (-e)

+ +

+This is the “refresh the leapfile this long before it expires” option. +This option takes a string argument. +Specify how long before expiration the file is to be refreshed +Units are required, e.g. "-e 60 days" Note that larger values +imply more frequent refreshes. +"$PREFETCH" +

+ +

0.1.6 ntp-conf-file option (-f)

+ +

+This is the “location of the ntp.conf file” option. +This option takes a string argument. +Specify location of ntp.conf (used to make sure leapfile directive is +present and to default leapfile) +$NTPCONF +

+ +

0.1.7 force-update option (-F)

+ +

+This is the “force update of the leapfile” option. +Force update even if current file is OK and not close to expiring. +

+ +

0.1.8 update-leap exit status

+ +

One of the following exit values will be returned: +

+
0 (EXIT_SUCCESS)
Successful program execution. +
1 (EXIT_FAILURE)
The operation failed or the command syntax was not valid. +
+ + +

0.1.9 update-leap Usage

+ +
+ + +


+Previous: update-leap Usage, +Up: update-leap Invocation + +
+ +

0.1.10 update-leap Authors

+ + + diff --git a/scripts/update-leap/update-leap.man.in b/scripts/update-leap/update-leap.man.in new file mode 100644 index 000000000..7fc7838d6 --- /dev/null +++ b/scripts/update-leap/update-leap.man.in @@ -0,0 +1,168 @@ +.de1 NOP +. it 1 an-trap +. if \\n[.$] \,\\$*\/ +.. +.ie t \ +.ds B-Font [CB] +.ds I-Font [CI] +.ds R-Font [CR] +.el \ +.ds B-Font B +.ds I-Font I +.ds R-Font R +.TH update-leap 1update-leapman "22 Mar 2015" "ntp (4.2.8p1)" "User Commands" +.\" +.\" EDIT THIS FILE WITH CAUTION (in-mem file) +.\" +.\" It has been AutoGen-ed March 22, 2015 at 01:38:24 AM by AutoGen 5.18.5pre6 +.\" From the definitions update-leap-opts.def +.\" and the template file agman-cmd.tpl +.SH NAME +\f\*[B-Font]update-leap\fP +\- leap-seconds file manager/updater +.SH SYNOPSIS +\f\*[B-Font]update-leap\fP +.\" Mixture of short (flag) options and long options +[\f\*[B-Font]\-flags\f[]] +[\f\*[B-Font]\-flag\f[] [\f\*[I-Font]value\f[]]] +[\f\*[B-Font]\-\-option-name\f[][[=| ]\f\*[I-Font]value\f[]]] +.sp \n(Ppu +.ne 2 + +All arguments must be options. +.sp \n(Ppu +.ne 2 + +.SH DESCRIPTION +\f\*[B-Font]update-leap\fP +will validate the file currently on the local syste +and if necessary, updates leap-second definition file. +.sp \n(Ppu +.ne 2 + +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. +.sp \n(Ppu +.ne 2 + +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. +.sp \n(Ppu +.ne 2 + +If the current file is acceptable, no download or restart occurs. +.sp \n(Ppu +.ne 2 + +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS +.SH "OPTIONS" +.TP +.NOP \f\*[B-Font]\-s\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-source\-url\f[]=\f\*[I-Font]string\f[] +The URL of the master copy of the leapseconds file. +.sp +Specify the URL of the master copy to download +$LEAPSRC +.TP +.NOP \f\*[B-Font]\-4\f[], \f\*[B-Font]\-\-ipv4\f[] +Use only IPv4 addresses for DNS name resolution. +This option must not appear in combination with any of the following options: +ipv6. +.sp + Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = ipv6; + flags-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = prefer; + flags-cant = ipv4, ipv6; + value = p; + arg-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<- _EndOfDoc_ +Prefer IPv4 or IPv6 (as specified) addresses, but use either. +.TP +.NOP \f\*[B-Font]\-d\f[] \f\*[I-Font]float\f[], \f\*[B-Font]\-\-destination\f[]=\f\*[I-Font]float\f[] +Filename on the local system. +.sp +The name to use to store the leapfile on the local system. +$LEAPFILE +.TP +.NOP \f\*[B-Font]\-e\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-expiration\f[]=\f\*[I-Font]string\f[] +Refresh the leapfile this long before it expires. +.sp +Specify how long before expiration the file is to be refreshed +Units are required, e.g. "-e 60 days" Note that larger values +imply more frequent refreshes. +"$PREFETCH" +.TP +.NOP \f\*[B-Font]\-f\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-ntp\-conf\-file\f[]=\f\*[I-Font]string\f[] +Location of the ntp.conf file. +.sp +Specify location of ntp.conf (used to make sure leapfile directive is +present and to default leapfile) +$NTPCONF +.TP +.NOP \f\*[B-Font]\-F\f[], \f\*[B-Font]\-\-force\-update\f[] +Force update of the leapfile. +.sp +Force update even if current file is OK and not close to expiring. +.TP +.NOP \f\*[B-Font]\-\-dont\-wait\f[] +Don't wait for keystroke between plots. +.sp +.TP +.NOP \f\*[B-Font]\-\&?\f[], \f\*[B-Font]\-\-help\f[] +Display usage information and exit. +.TP +.NOP \f\*[B-Font]\-\&!\f[], \f\*[B-Font]\-\-more-help\f[] +Pass the extended usage information through a pager. +.TP +.NOP \f\*[B-Font]\-v\f[] [{\f\*[I-Font]v|c|n\f[] \f\*[B-Font]\-\-version\f[] [{\f\*[I-Font]v|c|n\f[]}]}] +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.PP +.SH USAGE +Usage stuff +.SH "EXIT STATUS" +One of the following exit values will be returned: +.TP +.NOP 0 " (EXIT_SUCCESS)" +Successful program execution. +.TP +.NOP 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.TP +.NOP 70 " (EX_SOFTWARE)" +libopts had an internal operational error. Please report +it to autogen-users@lists.sourceforge.net. Thank you. +.PP +.SH AUTHORS +.NOP "Timothe Litt" +.br +.SH "NOTES" +This manual page was \fIAutoGen\fP-erated from the \fBupdate-leap\fP +option definitions. diff --git a/scripts/update-leap/update-leap.mdoc.in b/scripts/update-leap/update-leap.mdoc.in new file mode 100644 index 000000000..e03921e9e --- /dev/null +++ b/scripts/update-leap/update-leap.mdoc.in @@ -0,0 +1,133 @@ +.Dd March 22 2015 +.Dt UPDATE_LEAP 1update-leapmdoc User Commands +.Os +.\" EDIT THIS FILE WITH CAUTION (update-leap-opts.mdoc) +.\" +.\" It has been AutoGen-ed March 22, 2015 at 01:21:23 AM by AutoGen 5.18.5pre6 +.\" From the definitions update-leap-opts.def +.\" and the template file agmdoc-cmd.tpl +.Sh NAME +.Nm update-leap +.Nd leap-seconds file manager/updater +.Sh SYNOPSIS +.Nm +.\" Mixture of short (flag) options and long options +.Op Fl flags +.Op Fl flag Op Ar value +.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc +.Pp +All arguments must be options. +.Pp +.Sh DESCRIPTION +.Nm +will validate the file currently on the local syste +and if necessary, updates leap\-second definition file. +.Pp +Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. +However, an alternate location can be specified on the command line. +.Pp +If the file does not exist, is not valid, has expired, or is expiring soon, +a new copy will be downloaded. If the new copy validates, it is installed and +NTP is (optionally) restarted. +.Pp +If the current file is acceptable, no download or restart occurs. +.Pp +-c can also be used to invoke another script to perform administrative +functions, e.g. to copy the file to other local systems. +.PP +This can be run as a cron job. As the file is rarely updated, and leap +seconds are announced at least one month in advance (usually longer), it +need not be run more frequently than about once every three weeks. +.PP +For cron\-friendly behavior, define CRONJOB=1 in the crontab. +.PP +This script depends on$REQUIREDCMDS +.Sh "OPTIONS" +.Bl -tag +.It Fl s Ar string , Fl \-source\-url Ns = Ns Ar string +The URL of the master copy of the leapseconds file. +.sp +Specify the URL of the master copy to download +$LEAPSRC +.It Fl 4 , Fl \-ipv4 +Use only IPv4 addresses for DNS name resolution. +This option must not appear in combination with any of the following options: +ipv6. +.sp + Force DNS resolution of following host names on the command line + to the IPv4 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = ipv6; + flags\-cant = ipv4, prefer; + value = 6; + descrip = "Use only IPv6 addresses for DNS name resolution"; + doc = <<\- _EndOfDoc_ + Force DNS resolution of following host names on the command line + to the IPv6 namespace. + _EndOfDoc_; +}; +.sp +flag = { + name = prefer; + flags\-cant = ipv4, ipv6; + value = p; + arg\-type = keyword; + keyword = 4, 6; + descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either'; + doc = <<\- _EndOfDoc_ +Prefer IPv4 or IPv6 (as specified) addresses, but use either. +.It Fl d Ar float , Fl \-destination Ns = Ns Ar float +Filename on the local system. +.sp +The name to use to store the leapfile on the local system. +$LEAPFILE +.It Fl e Ar string , Fl \-expiration Ns = Ns Ar string +Refresh the leapfile this long before it expires. +.sp +Specify how long before expiration the file is to be refreshed +Units are required, e.g. "\-e 60 days" Note that larger values +imply more frequent refreshes. +"$PREFETCH" +.It Fl f Ar string , Fl \-ntp\-conf\-file Ns = Ns Ar string +Location of the ntp.conf file. +.sp +Specify location of ntp.conf (used to make sure leapfile directive is +present and to default leapfile) +$NTPCONF +.It Fl F , Fl \-force\-update +Force update of the leapfile. +.sp +Force update even if current file is OK and not close to expiring. +.It Fl \-dont\-wait +Don't wait for keystroke between plots. +.sp +.It Fl \&? , Fl \-help +Display usage information and exit. +.It Fl \&! , Fl \-more\-help +Pass the extended usage information through a pager. +.It Fl v Op Brq Ar v|c|n Fl \-version Op Brq Ar v|c|n +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.El +.Sh USAGE +Usage stuff +.Sh "EXIT STATUS" +One of the following exit values will be returned: +.Bl -tag +.It 0 " (EXIT_SUCCESS)" +Successful program execution. +.It 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.It 70 " (EX_SOFTWARE)" +libopts had an internal operational error. Please report +it to autogen\-users@lists.sourceforge.net. Thank you. +.El +.Sh AUTHORS +.An "Timothe Litt" +.Sh "NOTES" +This manual page was \fIAutoGen\fP\-erated from the \fBupdate\-leap\fP +option definitions. diff --git a/scripts/update-leap/update-leap.texi b/scripts/update-leap/update-leap.texi new file mode 100644 index 000000000..1a96ae09b --- /dev/null +++ b/scripts/update-leap/update-leap.texi @@ -0,0 +1,43 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename update-leap.info +@settitle update-leap User's Manual +@include ../../sntp/include/version.texi +@paragraphindent 2 +@c %**end of header + +@ifinfo +This file documents the use of @code{update-leap}, +a program from +the NTP Project, +that is used to wait until @code{ntpd} has been able to +synchronize and stabilize the time on the current host. +@end ifinfo + +@direntry +* update-leap: (update-leap). Check the leapfile and update it if needed. +@end direntry + +@titlepage +@title update-leap User's Manual +@subtitle update-leap, version @value{VERSION}, @value{UPDATED} +@c @author Max @email{foo@ntp.org} +@end titlepage + +@c @page +@c @vskip 0pt plus 1filll + +@node Top, update-leap Description, (dir), (dir) + +This document describes the use of the NTP Project's @code{update-leap} program. + +This document applies to version @value{VERSION} of @code{update-leap}. + +@shortcontents + +@menu +* update-leap Description:: Description +* update-leap Invocation:: Invoking update-leap +@end menu + +@include invoke-update-leap.texi diff --git a/sntp/loc/darwin b/sntp/loc/darwin index c902860b6..37d2dcac7 100644 --- a/sntp/loc/darwin +++ b/sntp/loc/darwin @@ -12,3 +12,4 @@ ntpsweep,noinst,8 ntptime,sbin,8 ntptrace,sbin,8 sntp,bin,8 +update-leap,sbin,8 diff --git a/sntp/loc/debian b/sntp/loc/debian index 7bc895ae0..1242fdf97 100644 --- a/sntp/loc/debian +++ b/sntp/loc/debian @@ -15,3 +15,4 @@ ntptrace,bin,1 sntp,bin,1 tickadj,sbin,8 timetrim,sbin,8 +update-leap,sbin,8 diff --git a/sntp/loc/freebsd b/sntp/loc/freebsd index 7759e3156..587f998c1 100644 --- a/sntp/loc/freebsd +++ b/sntp/loc/freebsd @@ -12,3 +12,4 @@ ntptime,sbin,8 ntpsweep,noinst,8 ntptrace,sbin,8 sntp,sbin,8 +update-leap,sbin,8 diff --git a/sntp/loc/legacy b/sntp/loc/legacy index 46c63a283..5412971b2 100644 --- a/sntp/loc/legacy +++ b/sntp/loc/legacy @@ -15,3 +15,4 @@ ntptrace,bin,1 sntp,bin,1 tickadj,bin,1 timetrim,bin,1 +update-leap,bin,1 diff --git a/sntp/loc/netbsd b/sntp/loc/netbsd index fa79340db..200de2b59 100644 --- a/sntp/loc/netbsd +++ b/sntp/loc/netbsd @@ -12,3 +12,4 @@ ntpsweep,noinst,8 ntptime,sbin,8 ntptrace,sbin,8 sntp,sbin,1 +update-leap,sbin,8 diff --git a/sntp/loc/solaris b/sntp/loc/solaris index eca143843..a9b385301 100644 --- a/sntp/loc/solaris +++ b/sntp/loc/solaris @@ -14,3 +14,4 @@ ntptime,sbin,1m ntptrace,sbin,1m sntp,sbin,1m tickadj,sbin,1m +update-leap,sbin,1m diff --git a/sntp/m4/ntp_locinfo.m4 b/sntp/m4/ntp_locinfo.m4 index f045ac260..6701ba028 100644 --- a/sntp/m4/ntp_locinfo.m4 +++ b/sntp/m4/ntp_locinfo.m4 @@ -124,6 +124,12 @@ AC_SUBST([TIMETRIM_DL]) AC_SUBST([TIMETRIM_DS]) AC_SUBST([TIMETRIM_MS]) AC_SUBST([TIMETRIM_NI]) +AC_SUBST([UPDATE_LEAP_DB]) +AC_SUBST([UPDATE_LEAP_DL]) +AC_SUBST([UPDATE_LEAP_DS]) +AC_SUBST([UPDATE_LEAP_MS]) +AC_SUBST([UPDATE_LEAP_NI]) +AM_CONDITIONAL([INSTALL_UPDATE_LEAP], [test -z "$UPDATE_LEAP_NI" ]) ])dnl dnl ======================================================================