196c8483Yuri Pankov#
296c8483Yuri Pankov# CDDL HEADER START
396c8483Yuri Pankov#
496c8483Yuri Pankov# The contents of this file are subject to the terms of the
596c8483Yuri Pankov# Common Development and Distribution License (the "License").
696c8483Yuri Pankov# You may not use this file except in compliance with the License.
796c8483Yuri Pankov#
896c8483Yuri Pankov# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
996c8483Yuri Pankov# or http://www.opensolaris.org/os/licensing.
1096c8483Yuri Pankov# See the License for the specific language governing permissions
1196c8483Yuri Pankov# and limitations under the License.
1296c8483Yuri Pankov#
1396c8483Yuri Pankov# When distributing Covered Code, include this CDDL HEADER in each
1496c8483Yuri Pankov# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1596c8483Yuri Pankov# If applicable, add the following below this CDDL HEADER, with the
1696c8483Yuri Pankov# fields enclosed by brackets "[]" replaced with your own identifying
1796c8483Yuri Pankov# information: Portions Copyright [yyyy] [name of copyright owner]
1896c8483Yuri Pankov#
1996c8483Yuri Pankov# CDDL HEADER END
2096c8483Yuri Pankov#
2196c8483Yuri Pankov
2296c8483Yuri Pankov#
2396c8483Yuri Pankov# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2496c8483Yuri Pankov#
2596c8483Yuri Pankov
2696c8483Yuri Pankov#
2796c8483Yuri Pankov# NAME
2896c8483Yuri Pankov#	service_enable
2996c8483Yuri Pankov#
3096c8483Yuri Pankov# DESCRIPTION
3196c8483Yuri Pankov#	Enable service
3296c8483Yuri Pankov#
3396c8483Yuri Pankov# RETURN
3496c8483Yuri Pankov#	0 - enabled service
3596c8483Yuri Pankov#	1 - failed to enable service
3696c8483Yuri Pankov#
3796c8483Yuri Pankovservice_enable () {
3896c8483Yuri Pankov	smf=$1
3996c8483Yuri Pankov
4096c8483Yuri Pankov	status=$(svcprop -p restarter/state $smf)
4196c8483Yuri Pankov	if [[ $status == "online" ]]; then
4296c8483Yuri Pankov		cti_report "service '$smf' is already enabled"
4396c8483Yuri Pankov		return 0
4496c8483Yuri Pankov	fi
4596c8483Yuri Pankov
4696c8483Yuri Pankov	svcadm enable -rs $smf
4796c8483Yuri Pankov}
4896c8483Yuri Pankov
4996c8483Yuri Pankov#
5096c8483Yuri Pankov# NAME
5196c8483Yuri Pankov#	service_disable
5296c8483Yuri Pankov#
5396c8483Yuri Pankov# DESCRIPTION
5496c8483Yuri Pankov#	Disable service
5596c8483Yuri Pankov#
5696c8483Yuri Pankov# RETURN
5796c8483Yuri Pankov#	0 - disabled service
5896c8483Yuri Pankov#	1 - failed to disable service
5996c8483Yuri Pankov#
6096c8483Yuri Pankovservice_disable () {
6196c8483Yuri Pankov	smf=$1
6296c8483Yuri Pankov
6396c8483Yuri Pankov	status=$(svcprop -p restarter/state $smf)
6496c8483Yuri Pankov	if [[ $status == "disabled" ]]; then
6596c8483Yuri Pankov		cti_report "PASS: service '$smf' is already disabled"
6696c8483Yuri Pankov		return 0
6796c8483Yuri Pankov	fi
6896c8483Yuri Pankov	svcadm disable -s $smf
6996c8483Yuri Pankov}
7096c8483Yuri Pankov
7196c8483Yuri Pankov#
7296c8483Yuri Pankov# NAME
7396c8483Yuri Pankov#	service_restart
7496c8483Yuri Pankov#
7596c8483Yuri Pankov# DESCRIPTION
7696c8483Yuri Pankov#	Restart service
7796c8483Yuri Pankov#
7896c8483Yuri Pankov# RETURN
7996c8483Yuri Pankov#	0 - restarted service
8096c8483Yuri Pankov#	1 - failed to restart service
8196c8483Yuri Pankov#
8296c8483Yuri Pankovservice_restart () {
8396c8483Yuri Pankov	smf=$1
8496c8483Yuri Pankov
8596c8483Yuri Pankov	svcadm restart $smf
8696c8483Yuri Pankov}
87