1#!/bin/sh
2#
3# chkconfig: 345 91 45
4# description: Starts and stops the Samba winbind daemon to provide \
5# user and group information from a domain controller to linux.
6
7# Source function library.
8if [ -f /etc/init.d/functions ] ; then
9  . /etc/init.d/functions
10elif [ -f /etc/rc.d/init.d/functions ] ; then
11  . /etc/rc.d/init.d/functions
12else
13  exit 0
14fi
15
16# Source networking configuration.
17. /etc/sysconfig/network
18
19# Check that networking is up.
20[ ${NETWORKING} = "no" ] && exit 0
21
22CONFIG=/etc/samba/smb.conf
23
24# Check that smb.conf exists.
25[ -f $CONFIG ] || exit 0
26
27start() {
28	echo -n "Starting Winbind services: "
29	RETVAL=1
30	if [ "`egrep -i '(idmap.*uid|winbind.*uid)' $CONFIG | egrep -v [\#\;]`" ]; then
31		daemon winbindd 
32		RETVAL=$?
33	fi
34	echo
35	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/winbind || \
36	   RETVAL=1
37	return $RETVAL
38}	
39stop() {
40	echo -n "Shutting down Winbind services: "
41	RETVAL=1
42	if [ "`egrep -i '(idmap.*uid|winbind.*uid)' $CONFIG | egrep -v [\#\;]`" ]; then
43		killproc winbindd
44		RETVAL=$?
45	fi
46	echo
47	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/winbind
48	return $RETVAL
49}	
50restart() {
51	stop
52	start
53}	
54reload() {
55	export TMPDIR="/var/tmp"
56        echo -n "Checking domain trusts: "
57	killproc winbindd -HUP
58	RETVAL=$?
59	echo
60	return $RETVAL
61}	
62mdkstatus() {
63	status winbindd
64}	
65
66case "$1" in
67  start)
68  	start
69	;;
70  stop)
71  	stop
72	;;
73  restart)
74  	restart
75	;;
76  reload)
77  	reload
78	;;
79  status)
80  	mdkstatus
81	;;
82  condrestart)
83  	[ -f /var/lock/subsys/winbindd ] && restart || :
84	;;
85  *)
86	echo "Usage: $0 {start|stop|restart|status|condrestart}"
87	exit 1
88esac
89
90exit $?
91