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]
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
26 # ident "%Z%%M% %I% %E% SMI"
28 . /lib/svc/share/smf_include.sh
31 # Given the exit status of a command, an integer, 0 if the command completed
32 # without errors. If the command exited with errors we degrade the
33 # state of this service into maintenance mode. If a 3rd argument is presented
34 # we don't degrade the service. We also log an error message as passed into
37 function check_failure { # integer exit status, error message, non-fatal flag
43 if [ $RESULT -ne 0 ] ; then
44 print_log "Error: $ERR_MSG"
45 if [ -z "${NON_FATAL}" ] ; then
46 print_log "Moving service $SMF_FMRI to maintenance mode."
47 svcadm mark maintenance $SMF_FMRI
54 # A function we use to emit output. Right now, this goes to syslog via logger(1)
55 # as well as being echoed to stdout which will result in it being picked up by
56 # SMF if the $LOG variable is null.
58 function print_log { # message to display
59 logger -t time-slider -p daemon.notice $*
63 # this function removes any left over cron jobs belonging to
64 # legacy zfs-auto-snapshot
66 function remove_legacy_cronjobs {
68 crontab -l | grep -v "/lib/svc/method/zfs-auto-snapshot" \
69 > /tmp/saved-crontab.$$
71 crontab /tmp/saved-crontab.$$
72 check_failure $? "Unable to remove legacy zfs-auto-snaphot cron jobs" "NON_FATAL"
74 rm /tmp/saved-crontab.$$
80 remove_legacy_cronjobs
82 [ ! -x /usr/lib/time-sliderd ] && exit $SMF_EXIT_ERR_CONFIG
86 if [ $err -ne 0 ]; then
87 echo "Time Slider failed to start: error $err"
88 exit $SMF_EXIT_ERR_FATAL
92 echo "Usage: $0 { start }"
93 exit $SMF_EXIT_ERR_FATAL