import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
[metze/old/v3-2-winbind-ndr.git] / packaging / Mandrake / winbind.init
1 #!/bin/sh
2 #
3 # chkconfig: 345 81 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.
8 if [ -f /etc/init.d/functions ] ; then
9   . /etc/init.d/functions
10 elif [ -f /etc/rc.d/init.d/functions ] ; then
11   . /etc/rc.d/init.d/functions
12 else
13   exit 0
14 fi
15
16 # Source networking configuration.
17 . /etc/sysconfig/network
18
19 # Check that networking is up.
20 [ ${NETWORKING} = "no" ] && exit 0
21
22 # Check that smb.conf exists.
23 [ -f /etc/samba/smb.conf ] || exit 0
24
25 RETVAL=0
26
27
28 start() {
29         echo -n "Starting Winbind services: "
30         RETVAL=1
31         if [ "`grep -i -E '(idmap|winbind) uid' /etc/samba/smb.conf | egrep -v [\#\;]`" -a "`grep -i -E '(idmap|winbind) gid' /etc/samba/smb.conf | egrep -v [\#\;]`" ]; then
32                 daemon winbindd
33                 RETVAL=$?
34         else
35                 echo "Winbind is not configured in /etc/samba/smb.conf, not starting"
36         fi
37         echo
38         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/winbind || \
39            RETVAL=1
40         return $RETVAL
41 }       
42 stop() {
43         echo -n "Shutting down Winbind services: "
44         RETVAL=1
45         if [ "`grep -i 'winbind uid' /etc/samba/smb.conf | egrep -v [\#\;]`" -a "`grep -i 'idmap gid' /etc/samba/smb.conf | egrep -v [\#\;]`" ]; then
46                 killproc winbindd
47                 RETVAL=$?
48         fi
49         echo
50         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/winbind
51         return $RETVAL
52 }       
53 restart() {
54         stop
55         start
56 }       
57 reload() {
58         export TMPDIR="/var/tmp"
59         echo -n "Checking domain trusts: "
60         killproc winbindd -HUP
61         RETVAL=$?
62         echo
63         return $RETVAL
64 }       
65 mdkstatus() {
66         status winbindd
67 }       
68
69 case "$1" in
70   start)
71         start
72         ;;
73   stop)
74         stop
75         ;;
76   restart)
77         restart
78         ;;
79   reload)
80         reload
81         ;;
82   status)
83         mdkstatus
84         ;;
85   condrestart)
86         [ -f /var/lock/subsys/winbindd ] && restart || :
87         ;;
88   *)
89         echo "Usage: $0 {start|stop|restart|status|condrestart}"
90         exit 1
91 esac
92
93 exit $?