]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - etc/rc.d/ntpdate
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 rcvar="ntpdate_enable"
14 stop_cmd=":"
15 start_cmd="ntpdate_start"
16
17 ntpdate_start()
18 {
19         if [ -z "$ntpdate_hosts" -a -f "$ntpdate_config" ]; then
20                 ntpdate_hosts=`awk '
21                         /^server[ \t]*127.127/      {next}
22                         /^(server|peer)/            {
23                             if ($2 ~/^-/)           {print $3}
24                             else                    {print $2}}
25                 ' < "$ntpdate_config"`
26         fi
27         if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then
28                 echo "Setting date via ntp."
29                 ${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts
30         fi
31 }
32
33 load_rc_config $name
34 run_rc_command "$1"