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