]> git.pld-linux.org Git - packages/samba.git/blob - winbind.init
- simplify
[packages/samba.git] / winbind.init
1 #!/bin/sh
2 #
3 # chkconfig:    345 91 35
4 # description:  Starts and stops the Samba winbind daemon to provide\
5 #               user and group information from a NT domain controller to linux.
6 #
7 # config:       /etc/samba/smb.conf
8
9 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
10
11 # Source function library.
12 . /etc/rc.d/init.d/functions
13
14 # Source networking configuration.
15 . /etc/sysconfig/network
16
17 # Daemon specific configuration.
18 . /etc/sysconfig/winbind
19
20 # Check that networking is up.
21 if is_yes "${NETWORKING}"; then
22         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
23                 msg_network_down winbindd
24                 exit 1
25         fi
26 else
27         exit 0
28 fi
29
30 TMPDIR="/tmp"; export TMPDIR
31
32 # Check that smb.conf exists.
33 [ -f /etc/samba/smb.conf ] || exit 0
34
35 # return true if 'idmap uid' or 'idmap gid' is set in samba config
36 configtest() {
37         egrep -qvi '^idmap [ug]id' /etc/samba/smb.conf
38 }
39
40 start() {
41         if [ ! -f /var/lock/subsys/winbind ]; then
42                 if configtest; then
43                         msg_starting winbindd
44                         daemon /usr/sbin/winbindd
45                         RETVAL=$?
46                         if [ $RETVAL -eq 0 ]; then
47                                 touch /var/lock/subsys/winbind
48                                 RETVAL=1
49                         fi
50                 else
51                         nls "Winbind is not configured in /etc/samba/smb.conf, not starting"
52                 fi
53         else
54                 msg_already_running winbindd
55         fi
56 }
57
58 stop() {
59         if [ -f /var/lock/subsys/winbind ]; then
60                 msg_stopping winbindd
61                 killproc winbindd
62                 rm -f /var/lock/subsys/winbind >/dev/null 2>&1
63         else
64                 msg_not_running winbindd
65         fi
66 }
67
68 condrestart() {
69         if [ -f /var/lock/subsys/winbind ]; then
70                 stop
71                 start
72         else
73                 msg_not_running winbindd
74                 RETVAL=$1
75         fi
76 }
77
78 RETVAL=0
79 # See how we were called.
80 case "$1" in
81   start)
82         start
83         ;;
84   stop)
85         stop
86         ;;
87   restart)
88         stop
89         start
90         ;;
91   reload|force-reload)
92         if [ -f /var/lock/subsys/winbind ]; then
93                 msg_reloading winbindd
94                 killproc winbindd -HUP
95                 RETVAL=$?
96         else
97                 msg_not_running winbindd
98                 exit 7
99         fi
100         ;;
101   try-restart)
102         condrestart 0
103         ;;
104   status)
105         status winbindd
106         RETVAL=$?
107         ;;
108   *)
109         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
110         exit 3
111 esac
112
113 exit $RETVAL
This page took 0.034684 seconds and 4 git commands to generate.