15758029 SUNBT7116639 Winbind SMF service should detect its failure s11u1-sru
authorVladimir Marek <Vladimir.Marek@oracle.com>
Thu, 31 Jan 2013 20:17:56 +0100
branchs11u1-sru
changeset 2513 8507b46f64f5
parent 2511 4a3540719f56
child 2514 16814427f988
15758029 SUNBT7116639 Winbind SMF service should detect its failure
components/samba/samba/Solaris/samba.sh
--- a/components/samba/samba/Solaris/samba.sh	Mon Mar 04 21:41:55 2013 +0100
+++ b/components/samba/samba/Solaris/samba.sh	Thu Jan 31 20:17:56 2013 +0100
@@ -22,13 +22,32 @@
 #
 
 #
-# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
 #
 
 . /lib/svc/share/smf_include.sh
 
 SAMBA_CONFIG=/etc/samba/smb.conf
 
+# Check if given service is working properly
+check_running() {
+	case "$SMF_FMRI" in
+		svc:/network/winbind:*)
+			# It takes some time before winbind starts to really work
+			# This is infinite loop which will be killed after smf timeout
+			while : ; do
+				sleep 2
+				PING=`/usr/bin/wbinfo --ping-dc 2>&1`
+				if [ $? -eq 0 ]; then
+					break
+				fi
+				echo "$PING"
+			done
+			;;
+	esac
+	return 0
+}
+
 case "$1" in
 	start)
 		if [ ! -f "$SAMBA_CONFIG" ]; then
@@ -39,6 +58,7 @@
 		# Command to execute is found in second and further script arguments
 		shift
 		eval "[email protected]"
+		check_running
 		;;
 	stop)
 		# kill whole contract group