HEX
Server: nginx/1.29.3
System: Linux mail.sarafai.ru 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: root (0)
PHP: 7.4.33
Disabled: dl,exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: //sbin/ntpdate
#! /bin/sh
#
# ntpdate - emulate the crufty old ntpdate utility from NTP Classic
#
# Not documented, as this is strictly a backward-compatibility shim. It's
# based on the recipes at
#           http://support.ntp.org/bin/view/Dev/DeprecatingNtpdate
# with corrections for modern ntpdig options.
#
# Debug this by giving the -n option, which causes it to echo the
# generated ntpdig command rather than executing it.
#
# Known bugs:
# * The -e and -p options of ntpdate are not yet implemented.
# * ntpdate took 4 samples and chose the best (shortest trip time).
#   This takes the first.
#
# ntpdate ntpdig  ntpd    What it does
# -4      -4      -q -4   Resolve DNS lookups to A records
# -6      -6      -q -6   Resolve DNS lookups to AAAA records
# -a N    -a N    -q      Authentication
# -b      -S      -q      step time adjustments
# -B      -s      -q      slew time adjustments
# -d      -d      -d      debugging mode (implies -q)
# -e N.N          -q      authdelay
# -k file -k file -k file key file
# -o N            -q      NTP Protocol version
# -p N            -q      How many samples to take
# -q      default -q      query/report only, don't set clock
#                         (implies -u for ntpdate)
# -s                      log to syslog (always enabled in ntpd)
# -t N.N  -t N.N          request timeout
# -u      default         unpriv port
# -v                      verbose (ntpd is always more verbose than ntpdate)
#         -c name         Send concurrent requests to resolved IPs for name
#
#         -l file         Log to file
#         -M msec         Slew adjustments less than msec,
#                         step adjustments larger than msec.
#
# SPDX-License-Identifier: BSD-2-Clause

print_help() {
	echo "Usage: ntpdate [OPTIONS] HOST..."
	echo
	echo "Options:"
	echo "	-4	Force IPv4 DNS name resolution"
	echo "	-6	Force IPv6 DNS name resolution"
	echo "	-a N	Specify key number for authentication"
	echo "	-b	Force time step"
	echo "	-B	Force time slew"
	echo "	-k FILE	Specify key file"
	echo "	-q	Query only"
	echo "	-s	Log to syslog"
	echo "	-t N.N	Specify timeout"
	echo "	-h 	Print help"
}

PASSTHROUGH=""
ADJUST=""
TIMEOUT="-t 1"
setclock=yes
echo=no
log=no
while getopts 46a:bBde:hk:no:p:qst:uv opt
do
    case $opt in
	4) PASSTHROUGH="$PASSTHROUGH -4";;
	6) PASSTHROUGH="$PASSTHROUGH -6";;
	a) PASSTHROUGH="$PASSTHROUGH -a $OPTARG";;
	b) ADJUST="$ADJUST -S";;
	B) ADJUST="$ADJUST -s";;
	d) PASSTHROUGH="$PASSTHROUGH -d";;
	e) echo "ntpdate: -e is no longer supported." >&2;;
	h) print_help; exit;;
	k) PASSTHROUGH="$PASSTHROUGH -k $OPTARG";;
	n) echo=yes;;			# Echo generated command, don't execute
	o) echo "ntpdate: -o is no longer supported." >&2;;
	p) echo "ntpdate: -p is no longer supported." >&2;;
	q) setclock=no;;
	s) log=yes;;
	t) PASSTHROUGH="$PASSTHROUGH -t $OPTARG"; TIMEOUT="";;
	u) ;;
	v) ;;
    esac
done
shift $(($OPTIND - 1))

if [ "$setclock" = yes -a -z "$ADJUST" ]
then
    ADJUST="-s -S -M 500"
fi

if [ "$echo" = yes ]
then
    echo ntpdig $ADJUST $TIMEOUT $PASSTHROUGH $*
else
    if [ "$log" = yes ]
    then
        ntpdig $ADJUST $TIMEOUT $PASSTHROUGH $* 2>&1 | logger -t ntpdate
    else
        ntpdig $ADJUST $TIMEOUT $PASSTHROUGH $*
    fi
fi

#end