libsoup3: update to 3.6.0; fix GTK2/3 app startup
[oi-userland.git] / components / network / ntp / Solaris / ntp.sh
blob181e4283c299060fbe46d323f6e9ec5056410e25
1 #!/sbin/sh
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
27 # Standard prolog
29 . /lib/svc/share/smf_include.sh
31 if [ -z $SMF_FMRI ]; then
32 echo "SMF framework variables are not initialized."
33 exit $SMF_EXIT_ERR
37 # Is NTP configured?
39 if [ ! -f /etc/inet/ntp.conf ]; then
40 echo "Error: Configuration file '/etc/inet/ntp.conf' not found." \
41 " See ntpd(1M)."
42 exit $SMF_EXIT_ERR_CONFIG
45 # Disable globbing to prevent privilege escalations by users authorized
46 # to set property values for the NTP service.
47 set -f
50 # Build the command line flags
52 shift $#
53 set -- -p /var/run/ntp.pid
54 # We allow a step larger than the panic value of 17 minutes only
55 # once when ntpd starts up. If always_all_large_step is true,
56 # then we allow this each time ntpd starts. Otherwise, we allow
57 # it only the very first time ntpd starts after a boot. We
58 # check that by making ntpd write its pid to a file in /var/run.
60 val=`svcprop -c -p config/always_allow_large_step $SMF_FMRI`
61 if [ "$val" = "true" ] || \
62 [ ! -f /var/run/ntp.pid ]; then
63 set -- "$@" -g
66 # Auth was off by default in xntpd now the default is on. Better have a way
67 # to turn it off again. Also check for the obsolete "authentication" keyword.
68 val=`svcprop -c -p config/no_auth_required $SMF_FMRI`
69 if [ ! "$val" = "true" ]; then
70 val=`/usr/bin/nawk '/^[ \t]*#/{next}
71 /^[ \t]*authentication[ \t]+no/ {
72 printf("true", $2)
73 next } ' /etc/inet/ntp.conf`
75 [ "$val" = "true" ] && set -- "$@" --authnoreq
77 # Set up logging if requested.
78 logfile=`svcprop -c -p config/logfile $SMF_FMRI`
79 val=`svcprop -c -p config/verbose_logging $SMF_FMRI`
80 [ "$val" = "true" ] && [ -n "$logfile" ] && set -- "$@" -l $logfile
82 # Register with mDNS.
83 val=`svcprop -c -p config/mdnsregister $SMF_FMRI`
84 mdns=`svcprop -c -p general/enabled svc:/network/dns/multicast:default`
85 [ "$val" = "true" ] && [ "$mdns" = "true" ] && set -- "$@" -m
87 # We used to support the slewalways keyword, but that was a Sun thing
88 # and not in V4. Look for "slewalways yes" and set the new slew option.
89 slew_always=`svcprop -c -p config/slew_always $SMF_FMRI`
90 if [ ! "$slew_always" = "true" ]; then
91 slew_always=`/usr/bin/nawk '/^[ \t]*#/{next}
92 /^[ \t]*slewalways[ \t]+yes/ {
93 printf("true", $2)
94 next } ' /etc/inet/ntp.conf`
96 [ "$slew_always" = "true" ] && set -- "$@" --slew
98 # Set up debugging.
99 deb=`svcprop -c -p config/debuglevel $SMF_FMRI`
101 # If slew_always is set to true, then the large offset after a reboot
102 # might take a very long time to correct the clock. Optionally allow
103 # a step once after a reboot if slew_always is set when allow_step_at_boot
104 # is also set.
105 val=`svcprop -c -p config/allow_step_at_boot $SMF_FMRI`
106 if [ "$val" = "true" ] && [ "$slew_always" = "true" ] && \
107 [ ! -f /var/run/ntp.pid ]; then
108 set -- "$@" --force-step-once
111 # Start the daemon. If debugging is requested, put it in the background,
112 # since it won't do it on it's own.
113 if [ "$deb" -gt 0 ]; then
114 /usr/lib/inet/ntpd "$@" --set-debug-level=$deb >/var/ntp/ntp.debug &
115 else
116 /usr/lib/inet/ntpd "$@"
119 # Now, wait for the first sync, if requested.
120 val=`svcprop -c -p config/wait_for_sync $SMF_FMRI`
121 [ "$val" = "true" ] && /usr/lib/inet/ntp-wait
123 exit $SMF_EXIT_OK