|
1 #!/sbin/sh |
|
2 # |
|
3 # CDDL HEADER START |
|
4 # |
|
5 # The contents of this file are subject to the terms of the |
|
6 # Common Development and Distribution License (the "License"). |
|
7 # You may not use this file except in compliance with the License. |
|
8 # |
|
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 # or http://www.opensolaris.org/os/licensing. |
|
11 # See the License for the specific language governing permissions |
|
12 # and limitations under the License. |
|
13 # |
|
14 # When distributing Covered Code, include this CDDL HEADER in each |
|
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 # If applicable, add the following below this CDDL HEADER, with the |
|
17 # fields enclosed by brackets "[]" replaced with your own identifying |
|
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 # |
|
20 # CDDL HEADER END |
|
21 # |
|
22 |
|
23 # |
|
24 # Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
|
25 # |
|
26 |
|
27 # Standard prolog |
|
28 # |
|
29 . /lib/svc/share/smf_include.sh |
|
30 |
|
31 smf_is_globalzone || exit $SMF_EXIT_OK |
|
32 |
|
33 if [ -z $SMF_FMRI ]; then |
|
34 echo "SMF framework variables are not initialized." |
|
35 exit $SMF_EXIT_ERR |
|
36 fi |
|
37 |
|
38 # |
|
39 # Is NTP configured? |
|
40 # |
|
41 if [ ! -f /etc/inet/ntp.conf ]; then |
|
42 echo "Error: Configuration file '/etc/inet/ntp.conf' not found." \ |
|
43 " See ntpd(1M)." |
|
44 exit $SMF_EXIT_ERR_CONFIG |
|
45 fi |
|
46 |
|
47 # Disable globbing to prevent privilege escalations by users authorized |
|
48 # to set property values for the NTP service. |
|
49 set -f |
|
50 |
|
51 # |
|
52 # Build the command line flags |
|
53 # |
|
54 shift $# |
|
55 set -- -p /var/run/ntp.pid |
|
56 # We allow a step large than the panic value of 17 minutes only |
|
57 # once when ntpd starts up. If always_all_large_step is true, |
|
58 # then we allow this each time ntpd starts. Otherwise, we allow |
|
59 # it only the very first time ntpd starts after a boot. We |
|
60 # check that by making ntpd write its pid to a file in /var/run. |
|
61 |
|
62 val=`svcprop -c -p config/always_allow_large_step $SMF_FMRI` |
|
63 if [ "$val" = "true" ] || \ |
|
64 [ ! -f /var/run/ntp.pid ]; then |
|
65 set -- "$@" -g |
|
66 fi |
|
67 |
|
68 # Auth was off by default in xntpd now the default is on. Better have a way |
|
69 # to turn it off again. Also check for the obsolete "authenitcation" keyword. |
|
70 val=`svcprop -c -p config/no_auth_required $SMF_FMRI` |
|
71 if [ ! "$val" = "true" ]; then |
|
72 val=`/usr/bin/nawk '/^[ \t]*#/{next} |
|
73 /^[ \t]*authentication[ \t]+no/ { |
|
74 printf("true", $2) |
|
75 next } ' /etc/inet/ntp.conf` |
|
76 fi |
|
77 [ "$val" = "true" ] && set -- "$@" --authnoreq |
|
78 |
|
79 # Set up logging if requested. |
|
80 logfile=`svcprop -c -p config/logfile $SMF_FMRI` |
|
81 val=`svcprop -c -p config/verbose_logging $SMF_FMRI` |
|
82 [ "$val" = "true" ] && [ -n "$logfile" ] && set -- "$@" -l $logfile |
|
83 |
|
84 # Register with mDNS. |
|
85 val=`svcprop -c -p config/mdnsregister $SMF_FMRI` |
|
86 mdns=`svcprop -c -p general/enabled svc:/network/dns/multicast:default` |
|
87 [ "$val" = "true" ] && [ "$mdns" = "true" ] && set -- "$@" -m |
|
88 |
|
89 # We used to support the slewalways keyword, but that was a Sun thing |
|
90 # and not in V4. Look for "slewalways yes" and set the new slew option. |
|
91 val=`svcprop -c -p config/slew_always $SMF_FMRI` |
|
92 if [ ! "$val" = "true" ]; then |
|
93 val=`/usr/bin/nawk '/^[ \t]*#/{next} |
|
94 /^[ \t]*slewalways[ \t]+yes/ { |
|
95 printf("true", $2) |
|
96 next } ' /etc/inet/ntp.conf` |
|
97 fi |
|
98 [ "$val" = "true" ] && set -- "$@" --slew |
|
99 |
|
100 # Set up debugging. |
|
101 deb=`svcprop -c -p config/debuglevel $SMF_FMRI` |
|
102 |
|
103 # Start the daemon. If debugging is requested, put it in the background, |
|
104 # since it won't do it on it's own. |
|
105 if [ "$deb" -gt 0 ]; then |
|
106 /usr/lib/inet/ntpd "$@" --set-debug-level=$deb >/var/ntp/ntp.debug & |
|
107 else |
|
108 /usr/lib/inet/ntpd "$@" |
|
109 fi |
|
110 |
|
111 # Now, wait for the first sync, if requested. |
|
112 val=`svcprop -c -p config/wait_for_sync $SMF_FMRI` |
|
113 [ "$val" = "true" ] && /usr/lib/inet/ntp-wait |
|
114 |
|
115 exit $SMF_EXIT_OK |