]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/ntpdate
UPDATING: Add note about efifb support and serial output
[FreeBSD/FreeBSD.git] / etc / rc.d / ntpdate
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: ntpdate
7 # REQUIRE: NETWORKING syslogd
8 # KEYWORD: nojail
9
10 . /etc/rc.subr
11
12 name="ntpdate"
13 desc="Set the date and time via NTP"
14 rcvar="ntpdate_enable"
15 stop_cmd=":"
16 start_cmd="ntpdate_start"
17
18 ntpdate_start()
19 {
20         if [ -z "$ntpdate_hosts" -a -f "$ntpdate_config" ]; then
21                 ntpdate_hosts=`awk '
22                         /^server[ \t]*127.127/      {next}
23                         /^(server|peer|pool)/       {
24                             if ($2 ~/^-/)           {print $3}
25                             else                    {print $2}}
26                 ' < "$ntpdate_config"`
27         fi
28         if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then
29                 echo "Setting date via ntp."
30                 ${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts
31         fi
32 }
33
34 load_rc_config $name
35 run_rc_command "$1"