]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2769] New script: update-leap
authorHarlan Stenn <stenn@ntp.org>
Sun, 22 Mar 2015 03:01:33 +0000 (03:01 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 22 Mar 2015 03:01:33 +0000 (03:01 +0000)
bk: 550e308dq8pnMrB2_40r1ZogNR_yUg

22 files changed:
ChangeLog
configure.ac
scripts/Makefile.am
scripts/update-leap/Makefile.am [new file with mode: 0644]
scripts/update-leap/invoke-update-leap.menu [new file with mode: 0644]
scripts/update-leap/invoke-update-leap.texi [new file with mode: 0644]
scripts/update-leap/update-leap [new file with mode: 0644]
scripts/update-leap/update-leap-opts [new file with mode: 0644]
scripts/update-leap/update-leap-opts.def [new file with mode: 0644]
scripts/update-leap/update-leap.1update-leapman [new file with mode: 0644]
scripts/update-leap/update-leap.1update-leapmdoc [new file with mode: 0644]
scripts/update-leap/update-leap.html [new file with mode: 0644]
scripts/update-leap/update-leap.man.in [new file with mode: 0644]
scripts/update-leap/update-leap.mdoc.in [new file with mode: 0644]
scripts/update-leap/update-leap.texi [new file with mode: 0644]
sntp/loc/darwin
sntp/loc/debian
sntp/loc/freebsd
sntp/loc/legacy
sntp/loc/netbsd
sntp/loc/solaris
sntp/m4/ntp_locinfo.m4

index 04fb22a9d9d4188e20541d27d216fb2d1f208365..00f92dd0a695e3e8a9bb17651415c2fee3856e03 100644 (file)
--- 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
index 11881775b169aaf450744b59f76df5ba91838d39..dc5c7fcfd7035fff58c67b268a6e5af857486c71 100644 (file)
@@ -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])
index 7ddf4247bf4798e42d1ab3560760e960ac3ff0fa..2664bef4def8c6f28a2077dab631ed911fc6da0b 100644 (file)
@@ -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 (file)
index 0000000..bfcfc2c
--- /dev/null
@@ -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 (file)
index 0000000..e27e349
--- /dev/null
@@ -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 (file)
index 0000000..f85978e
--- /dev/null
@@ -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 (file)
index 0000000..2dab4ec
--- /dev/null
@@ -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 <<EOF
+Usage: $SELF [options] [leapfile]
+
+Verifies and if necessary, updates leap-second definition file
+
+All arguments are optional:  Default (or current value) shown:
+    -s    Specify the URL of the master copy to download
+          $LEAPSRC
+    -4    Use only IPv4
+    -6    Use only IPv6
+    -p 4|6
+          Prefer IPv4 or IPv6 (as specified) addresses, but use either
+    -d    Specify the filename on the local system
+          $LEAPFILE
+    -e    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"
+    -f    Specify location of ntp.conf (used to make sure leapfile directive is
+          present and to default  leapfile)
+          $NTPCONF
+    -F    Force update even if current file is OK and not close to expiring.
+    -c    Command to restart NTP after installing a new file
+          <none> - 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 (file)
index 0000000..79beb08
--- /dev/null
@@ -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 [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 
+
+    -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 (file)
index 0000000..2f90d1f
--- /dev/null
@@ -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 (file)
index 0000000..7fc7838
--- /dev/null
@@ -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 (file)
index 0000000..e03921e
--- /dev/null
@@ -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 (file)
index 0000000..e0b876a
--- /dev/null
@@ -0,0 +1,297 @@
+<html lang="en">
+<head>
+<title>update-leap User's Manual</title>
+<meta http-equiv="Content-Type" content="text/html">
+<meta name="description" content="update-leap User's Manual">
+<meta name="generator" content="makeinfo 4.13">
+<link title="Top" rel="top" href="#Top">
+<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css"><!--
+  pre.display { font-family:inherit }
+  pre.format  { font-family:inherit }
+  pre.smalldisplay { font-family:inherit; font-size:smaller }
+  pre.smallformat  { font-family:inherit; font-size:smaller }
+  pre.smallexample { font-size:smaller }
+  pre.smalllisp    { font-size:smaller }
+  span.sc    { font-variant:small-caps }
+  span.roman { font-family:serif; font-weight:normal; } 
+  span.sansserif { font-family:sans-serif; font-weight:normal; } 
+--></style>
+</head>
+<body>
+<h1 class="settitle">update-leap User's Manual</h1>
+<div class="node">
+<a name="Top"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-Description">update-leap Description</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
+
+</div>
+
+  <p>This document describes the use of the NTP Project's <code>update-leap</code> program.
+
+  <p>This document applies to version 4.2.8p1 of <code>update-leap</code>.
+
+<div class="shortcontents">
+<h2>Short Contents</h2>
+<ul>
+</ul>
+</div>
+
+<ul class="menu">
+<li><a accesskey="1" href="#update_002dleap-Description">update-leap Description</a>:             Description
+<li><a accesskey="2" href="#update_002dleap-Invocation">update-leap Invocation</a>:            Invoking update-leap
+</ul>
+
+<div class="node">
+<a name="update-leap-Invocation"></a>
+<a name="update_002dleap-Invocation"></a>
+<p><hr>
+
+
+</div>
+
+<h3 class="section">0.1 Invoking update-leap</h3>
+
+<p><a name="index-update_002dleap-1"></a><a name="index-leap_002dseconds-file-manager_002fupdater-2"></a>
+
+  <p><code>update-leap</code>
+will validate the file currently on the local syste
+and if necessary, updates leap-second definition file.
+
+  <p>Ordinarily, the file is found using the "leapfile" directive in $NTPCONF. 
+However, an alternate location can be specified on the command line.
+
+  <p>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.
+
+  <p>If the current file is acceptable, no download or restart occurs.
+
+  <p>-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
+
+  <p>This section was generated by <strong>AutoGen</strong>,
+using the <code>agtexi-cmd</code> template and the option descriptions for the <code>update-leap</code> program.
+
+<ul class="menu">
+<li><a accesskey="1" href="#update_002dleap-usage">update-leap usage</a>:                   update-leap help/usage (<samp><span class="option">--help</span></samp>)
+<li><a accesskey="2" href="#update_002dleap-source_002durl">update-leap source-url</a>:              source-url option (-s)
+<li><a accesskey="3" href="#update_002dleap-ipv4">update-leap ipv4</a>:                    ipv4 option (-4)
+<li><a accesskey="4" href="#update_002dleap-destination">update-leap destination</a>:             destination option (-d)
+<li><a accesskey="5" href="#update_002dleap-expiration">update-leap expiration</a>:              expiration option (-e)
+<li><a accesskey="6" href="#update_002dleap-ntp_002dconf_002dfile">update-leap ntp-conf-file</a>:           ntp-conf-file option (-f)
+<li><a accesskey="7" href="#update_002dleap-force_002dupdate">update-leap force-update</a>:            force-update option (-F)
+<li><a accesskey="8" href="#update_002dleap-exit-status">update-leap exit status</a>:             exit status
+<li><a accesskey="9" href="#update_002dleap-Usage">update-leap Usage</a>:                   Usage
+<li><a href="#update_002dleap-Authors">update-leap Authors</a>:                 Authors
+</ul>
+
+<div class="node">
+<a name="update-leap-usage"></a>
+<a name="update_002dleap-usage"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-source_002durl">update-leap source-url</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.1 update-leap help/usage (<samp><span class="option">--help</span></samp>)</h4>
+
+<p><a name="index-update_002dleap-help-3"></a>
+This is the automatically generated usage text for update-leap.
+
+  <p>The text printed is the same whether selected with the <code>help</code> option
+(<samp><span class="option">--help</span></samp>) or the <code>more-help</code> option (<samp><span class="option">--more-help</span></samp>).  <code>more-help</code> will print
+the usage text by passing it through a pager program. 
+<code>more-help</code> is disabled on platforms without a working
+<code>fork(2)</code> function.  The <code>PAGER</code> environment variable is
+used to select the program, defaulting to <samp><span class="file">more</span></samp>.  Both will exit
+with a status code of 0.
+
+<pre class="example">/bin/bash: line 135: ./update-leap: Permission denied
+</pre>
+  <div class="node">
+<a name="update-leap-source-url"></a>
+<a name="update_002dleap-source_002durl"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-ipv4">update-leap ipv4</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-usage">update-leap usage</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.2 source-url option (-s)</h4>
+
+<p><a name="index-update_002dleap_002dsource_002durl-4"></a>
+This is the &ldquo;the url of the master copy of the leapseconds file&rdquo; option. 
+This option takes a string argument. 
+Specify the URL of the master copy to download
+$LEAPSRC
+<div class="node">
+<a name="update-leap-ipv4"></a>
+<a name="update_002dleap-ipv4"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-destination">update-leap destination</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-source_002durl">update-leap source-url</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.3 ipv4 option (-4)</h4>
+
+<p><a name="index-update_002dleap_002dipv4-5"></a>
+This is the &ldquo;use only ipv4 addresses for dns name resolution&rdquo; option.
+
+<p class="noindent">This option has some usage constraints.  It:
+     <ul>
+<li>must not appear in combination with any of the following options:
+ipv6. 
+</ul>
+
+  <p>Force DNS resolution of following host names on the command line
+        to the IPv4 namespace. 
+        _EndOfDoc_;
+;
+
+  <p>flag = 
+    name      = ipv6;
+    flags-cant = ipv4, prefer;
+    value     = 6;
+    descrip   = "Use only IPv6 addresses for DNS name resolution";
+    doc = &lt;&lt;-  _EndOfDoc_
+        Force DNS resolution of following host names on the command line
+        to the IPv6 namespace. 
+        _EndOfDoc_;
+;
+
+  <p>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         = &lt;&lt;-  _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either. 
+<div class="node">
+<a name="update-leap-destination"></a>
+<a name="update_002dleap-destination"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-expiration">update-leap expiration</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-ipv4">update-leap ipv4</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.4 destination option (-d)</h4>
+
+<p><a name="index-update_002dleap_002ddestination-6"></a>
+This is the &ldquo;filename on the local system&rdquo; option. 
+This option takes a string argument <samp><span class="file">float</span></samp>. 
+The name to use to store the leapfile on the local system. 
+$LEAPFILE
+<div class="node">
+<a name="update-leap-expiration"></a>
+<a name="update_002dleap-expiration"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-ntp_002dconf_002dfile">update-leap ntp-conf-file</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-destination">update-leap destination</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.5 expiration option (-e)</h4>
+
+<p><a name="index-update_002dleap_002dexpiration-7"></a>
+This is the &ldquo;refresh the leapfile this long before it expires&rdquo; 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"
+<div class="node">
+<a name="update-leap-ntp-conf-file"></a>
+<a name="update_002dleap-ntp_002dconf_002dfile"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-force_002dupdate">update-leap force-update</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-expiration">update-leap expiration</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.6 ntp-conf-file option (-f)</h4>
+
+<p><a name="index-update_002dleap_002dntp_002dconf_002dfile-8"></a>
+This is the &ldquo;location of the ntp.conf file&rdquo; 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
+<div class="node">
+<a name="update-leap-force-update"></a>
+<a name="update_002dleap-force_002dupdate"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-exit-status">update-leap exit status</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-ntp_002dconf_002dfile">update-leap ntp-conf-file</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.7 force-update option (-F)</h4>
+
+<p><a name="index-update_002dleap_002dforce_002dupdate-9"></a>
+This is the &ldquo;force update of the leapfile&rdquo; option. 
+Force update even if current file is OK and not close to expiring. 
+<div class="node">
+<a name="update-leap-exit-status"></a>
+<a name="update_002dleap-exit-status"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-Usage">update-leap Usage</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-force_002dupdate">update-leap force-update</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.8 update-leap exit status</h4>
+
+<p>One of the following exit values will be returned:
+     <dl>
+<dt>&lsquo;<samp><span class="samp">0 (EXIT_SUCCESS)</span></samp>&rsquo;<dd>Successful program execution. 
+<br><dt>&lsquo;<samp><span class="samp">1 (EXIT_FAILURE)</span></samp>&rsquo;<dd>The operation failed or the command syntax was not valid. 
+</dl>
+  <div class="node">
+<a name="update-leap-Usage"></a>
+<a name="update_002dleap-Usage"></a>
+<p><hr>
+Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-Authors">update-leap Authors</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-exit-status">update-leap exit status</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.9 update-leap Usage</h4>
+
+<div class="node">
+<a name="update-leap-Authors"></a>
+<a name="update_002dleap-Authors"></a>
+<p><hr>
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-Usage">update-leap Usage</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+
+</div>
+
+<h4 class="subsection">0.1.10 update-leap Authors</h4>
+
+</body></html>
+
diff --git a/scripts/update-leap/update-leap.man.in b/scripts/update-leap/update-leap.man.in
new file mode 100644 (file)
index 0000000..7fc7838
--- /dev/null
@@ -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 (file)
index 0000000..e03921e
--- /dev/null
@@ -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 (file)
index 0000000..1a96ae0
--- /dev/null
@@ -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
index c902860b6a07523b6c11c049239276ac5d550202..37d2dcac7a9b7d07fbcfb06db9f8290f25c2029c 100644 (file)
@@ -12,3 +12,4 @@ ntpsweep,noinst,8
 ntptime,sbin,8
 ntptrace,sbin,8
 sntp,bin,8
+update-leap,sbin,8
index 7bc895ae010b6e4486ab70c7531a3d5c261a34a9..1242fdf97311013aafb48d744e3db88847ee6949 100644 (file)
@@ -15,3 +15,4 @@ ntptrace,bin,1
 sntp,bin,1
 tickadj,sbin,8
 timetrim,sbin,8
+update-leap,sbin,8
index 7759e315693a264acc5b395e2eff436cf44e17d1..587f998c153b6a9ddfcf218752e998618feddb0c 100644 (file)
@@ -12,3 +12,4 @@ ntptime,sbin,8
 ntpsweep,noinst,8
 ntptrace,sbin,8
 sntp,sbin,8
+update-leap,sbin,8
index 46c63a2831a6209f9a75d66ecadb8ad970aa2bc8..5412971b265ae3b3c28209afa0c0ff361be67eed 100644 (file)
@@ -15,3 +15,4 @@ ntptrace,bin,1
 sntp,bin,1
 tickadj,bin,1
 timetrim,bin,1
+update-leap,bin,1
index fa79340db23eb2d2ff43c0a419228fe2a7d4177a..200de2b5962012d10f94d4b5046f9925970417a5 100644 (file)
@@ -12,3 +12,4 @@ ntpsweep,noinst,8
 ntptime,sbin,8
 ntptrace,sbin,8
 sntp,sbin,1
+update-leap,sbin,8
index eca143843c4d99324c0fc93fbe30b4c0f3a8d6de..a9b3853018bca62c5f8217ce5dc67592ccbae868 100644 (file)
@@ -14,3 +14,4 @@ ntptime,sbin,1m
 ntptrace,sbin,1m
 sntp,sbin,1m
 tickadj,sbin,1m
+update-leap,sbin,1m
index f045ac2609d56808d97641343a0eec57f005c169..6701ba028b60fb90cd069ced6cd3d2a639ef9fb3 100644 (file)
@@ -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 ======================================================================