1 #!/sbin/sh |
|
2 |
|
3 # |
|
4 # CDDL HEADER START |
|
5 # |
|
6 # The contents of this file are subject to the terms of the |
|
7 # Common Development and Distribution License (the "License"). |
|
8 # You may not use this file except in compliance with the License. |
|
9 # |
|
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
11 # or http://www.opensolaris.org/os/licensing. |
|
12 # See the License for the specific language governing permissions |
|
13 # and limitations under the License. |
|
14 # |
|
15 # When distributing Covered Code, include this CDDL HEADER in each |
|
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
17 # If applicable, add the following below this CDDL HEADER, with the |
|
18 # fields enclosed by brackets "[]" replaced with your own identifying |
|
19 # information: Portions Copyright [yyyy] [name of copyright owner] |
|
20 # |
|
21 # CDDL HEADER END |
|
22 # |
|
23 |
|
24 # |
|
25 # Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
|
26 # |
|
27 |
|
28 . /lib/svc/share/smf_include.sh |
|
29 |
|
30 SAMBA_CONFIG=/etc/samba/smb.conf |
|
31 |
|
32 NSS_STRICT_NOFORK=DISABLED; export NSS_STRICT_NOFORK |
|
33 |
|
34 # Check if given service is working properly |
|
35 check_running() { |
|
36 case "$SMF_FMRI" in |
|
37 svc:/network/winbind:*) |
|
38 # It takes some time before winbind starts to really work |
|
39 # This is infinite loop which will be killed after smf timeout |
|
40 while : ; do |
|
41 sleep 2 |
|
42 PING=`/usr/bin/wbinfo -P 2>&1` |
|
43 if [ $? -eq 0 ]; then |
|
44 break |
|
45 fi |
|
46 echo "$PING" |
|
47 done |
|
48 ;; |
|
49 esac |
|
50 return 0 |
|
51 } |
|
52 |
|
53 case "$1" in |
|
54 start) |
|
55 if [ ! -f "$SAMBA_CONFIG" ]; then |
|
56 echo "Configuration file '$SAMBA_CONFIG' does not exist." |
|
57 exit 1 |
|
58 fi |
|
59 |
|
60 # Command to execute is found in second and further script arguments |
|
61 shift |
|
62 eval "$@" |
|
63 check_running |
|
64 ;; |
|
65 stop) |
|
66 # kill whole contract group |
|
67 |
|
68 # first send TERM signal and wait 30 seconds |
|
69 smf_kill_contract $2 TERM 1 30 |
|
70 ret=$? |
|
71 [ $ret -eq 1 ] && exit 1 |
|
72 |
|
73 # If there are still processes running, KILL them |
|
74 if [ $ret -eq 2 ] ; then |
|
75 smf_kill_contract $2 KILL 1 |
|
76 fi |
|
77 ;; |
|
78 *) |
|
79 cat <<-EOT |
|
80 Usage: |
|
81 $0 start <command to run> |
|
82 $0 stop <contract number to kill> |
|
83 EOT |
|
84 exit 1 |
|
85 ;; |
|
86 esac |
|