944N/A#!/sbin/sh
944N/A
944N/A#
944N/A# CDDL HEADER START
944N/A#
944N/A# The contents of this file are subject to the terms of the
944N/A# Common Development and Distribution License (the "License").
944N/A# You may not use this file except in compliance with the License.
944N/A#
944N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
944N/A# or http://www.opensolaris.org/os/licensing.
944N/A# See the License for the specific language governing permissions
944N/A# and limitations under the License.
944N/A#
944N/A# When distributing Covered Code, include this CDDL HEADER in each
944N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
944N/A# If applicable, add the following below this CDDL HEADER, with the
944N/A# fields enclosed by brackets "[]" replaced with your own identifying
944N/A# information: Portions Copyright [yyyy] [name of copyright owner]
944N/A#
944N/A# CDDL HEADER END
944N/A#
944N/A
944N/A#
1395N/A# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
944N/A#
944N/A
944N/A. /lib/svc/share/smf_include.sh
944N/A
944N/ASAMBA_CONFIG=/etc/samba/smb.conf
944N/A
1849N/ANSS_STRICT_NOFORK=DISABLED; export NSS_STRICT_NOFORK
1849N/A
1395N/A# Check if given service is working properly
1395N/Acheck_running() {
1395N/A case "$SMF_FMRI" in
1395N/A svc:/network/winbind:*)
1395N/A # It takes some time before winbind starts to really work
1395N/A # This is infinite loop which will be killed after smf timeout
1395N/A while : ; do
1395N/A sleep 2
4784N/A PING=`/usr/bin/wbinfo -P 2>&1`
1395N/A if [ $? -eq 0 ]; then
1395N/A break
1395N/A fi
1395N/A echo "$PING"
1395N/A done
1395N/A ;;
1395N/A esac
1395N/A return 0
1395N/A}
1395N/A
944N/Acase "$1" in
944N/A start)
944N/A if [ ! -f "$SAMBA_CONFIG" ]; then
944N/A echo "Configuration file '$SAMBA_CONFIG' does not exist."
944N/A exit 1
944N/A fi
944N/A
944N/A # Command to execute is found in second and further script arguments
944N/A shift
944N/A eval "$@"
1395N/A check_running
944N/A ;;
944N/A stop)
944N/A # kill whole contract group
944N/A
944N/A # first send TERM signal and wait 30 seconds
944N/A smf_kill_contract $2 TERM 1 30
944N/A ret=$?
944N/A [ $ret -eq 1 ] && exit 1
944N/A
944N/A # If there are still processes running, KILL them
944N/A if [ $ret -eq 2 ] ; then
944N/A smf_kill_contract $2 KILL 1
944N/A fi
944N/A ;;
944N/A *)
944N/A cat <<-EOT
944N/A Usage:
944N/A $0 start <command to run>
944N/A $0 stop <contract number to kill>
944N/A EOT
944N/A exit 1
944N/A ;;
944N/Aesac