libsmbclient: update to 4.4.6
[unleashed-userland.git] / components / network / samba / Solaris / samba.sh
blobe1d0029670b66341539eec7c96811c4dec40e804
1 #!/sbin/sh
4 # CDDL HEADER START
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.
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.
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]
21 # CDDL HEADER END
25 # Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
28 . /lib/svc/share/smf_include.sh
30 SAMBA_CONFIG=/etc/samba/smb.conf
32 NSS_STRICT_NOFORK=DISABLED; export NSS_STRICT_NOFORK
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 --ping-dc 2>&1`
43 if [ $? -eq 0 ]; then
44 break
46 echo "$PING"
47 done
49 esac
50 return 0
53 case "$1" in
54 start)
55 if [ ! -f "$SAMBA_CONFIG" ]; then
56 echo "Configuration file '$SAMBA_CONFIG' does not exist."
57 exit 1
60 # Command to execute is found in second and further script arguments
61 shift
62 eval "$@"
63 check_running
65 stop)
66 # kill whole contract group
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
73 # If there are still processes running, KILL them
74 if [ $ret -eq 2 ] ; then
75 smf_kill_contract $2 KILL 1
79 cat <<-EOT
80 Usage:
81 $0 start <command to run>
82 $0 stop <contract number to kill>
83 EOT
84 exit 1
86 esac