Home | History | Annotate | Line # | Download | only in rc.d
ntpdate revision 1.20.50.1
      1        1.1     lukem #!/bin/sh
      2        1.1     lukem #
      3  1.20.50.1       snj # $NetBSD: ntpdate,v 1.20.50.1 2020/12/28 16:00:19 snj Exp $
      4        1.1     lukem #
      5        1.1     lukem 
      6        1.1     lukem # PROVIDE: ntpdate
      7       1.19     perry # REQUIRE: NETWORKING mountcritremote syslogd named
      8       1.20     perry # BEFORE: ntpd
      9        1.1     lukem 
     10       1.16   mycroft $_rc_subr_loaded . /etc/rc.subr
     11        1.1     lukem 
     12        1.1     lukem name="ntpdate"
     13        1.6     lukem rcvar=$name
     14       1.13     fredb command="/usr/sbin/${name}"
     15        1.1     lukem start_cmd="ntpdate_start"
     16        1.1     lukem stop_cmd=":"
     17        1.1     lukem 
     18        1.1     lukem ntpdate_start()
     19        1.1     lukem {
     20        1.1     lukem 	if [ -z "$ntpdate_hosts" ]; then
     21       1.17  christos 		ntpdate_hosts=$(awk '
     22       1.10     lukem 			/^#/				{ next }
     23       1.10     lukem 			/^(server|peer)[ \t]*127.127/	{ next }
     24  1.20.50.1       snj 			/^(server|peer|pool)/		{ if ($2 ~ /^-[46]/)
     25       1.12     fredb 							    print $3
     26       1.12     fredb 							  else
     27       1.12     fredb 							    print $2 }
     28       1.17  christos 		' </etc/ntp.conf)
     29        1.1     lukem 	fi
     30        1.1     lukem 	if [ -n "$ntpdate_hosts"  ]; then
     31        1.1     lukem 		echo "Setting date via ntp."
     32       1.11     fredb 		$command $rc_flags $ntpdate_hosts
     33        1.1     lukem 	fi
     34        1.1     lukem }
     35        1.1     lukem 
     36        1.3     lukem load_rc_config $name
     37        1.1     lukem run_rc_command "$1"
     38