1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 #
25
26 #
27 # NAME
28 # service_enable
29 #
30 # DESCRIPTION
31 # Enable service
32 #
33 # RETURN
34 # 0 - enabled service
35 # 1 - failed to enable service
36 #
37 service_enable () {
38 smf=$1
39
40 status=$(svcprop -p restarter/state $smf)
41 if [[ $status == "online" ]]; then
42 cti_report "service '$smf' is already enabled"
43 return 0
44 fi
45
46 svcadm enable -rs $smf
47 }
48
49 #
50 # NAME
51 # service_disable
52 #
53 # DESCRIPTION
54 # Disable service
55 #
56 # RETURN
57 # 0 - disabled service
58 # 1 - failed to disable service
59 #
60 service_disable () {
61 smf=$1
62
63 status=$(svcprop -p restarter/state $smf)
64 if [[ $status == "disabled" ]]; then
65 cti_report "PASS: service '$smf' is already disabled"
66 return 0
67 fi
68 svcadm disable -s $smf
69 }
70
71 #
72 # NAME
73 # service_restart
74 #
75 # DESCRIPTION
76 # Restart service
77 #
78 # RETURN
79 # 0 - restarted service
80 # 1 - failed to restart service
81 #
82 service_restart () {
83 smf=$1
84
85 svcadm restart $smf
86 }