Initscript from 2.2.4 tree.
authorJohn Terpstra <jht@samba.org>
Sun, 10 Mar 2002 21:41:56 +0000 (21:41 +0000)
committerJohn Terpstra <jht@samba.org>
Sun, 10 Mar 2002 21:41:56 +0000 (21:41 +0000)
(This used to be commit d61f3810443a1828ea8c6c6782708f3ddd7caaea)

packaging/Caldera/OpenLinux/samba.init-lsb

index f14eef648faf8318947c5e27c73ba17e252b541c..615e17b21fca4285e6c0dcd5d1062e0c8c2b4a4f 100755 (executable)
@@ -21,6 +21,10 @@ NAME_S=smbd
 DAEMON_S=/usr/sbin/$NAME_S
 NAME_N=nmbd
 DAEMON_N=/usr/sbin/$NAME_N
+NAME_W=winbindd
+DAEMON_W=/usr/sbin/$NAME_W
+
+config_file=/etc/samba.d/smb.conf 
 
 # Source function library (and set vital variables).
 .  @SVIdir@/functions
@@ -36,14 +40,44 @@ status() {
   return 0               # seems to be up and running
 }
 
+# this function is dedicated to Jan Terpstra. -- Klaus Singvogel, Sep. 2001.
+WinbdConfig() {
+  # returns 0 if winbindd is not configured,
+  # and     1 if winbindd is configured.
+
+  local config_file=$1; shift   # file to check
+
+  # check if "winbind uid" is set in samba config file
+  egrep -q '[^#]*winbind uid' $config_file || return 0
+
+  found=0;
+  # We also need to check if least one PAM module control file does
+  # NOT have pam_winbind.so commented out
+  for i in /etc/pam.d/*; do
+    if [ ! -f $i ]; then next; fi
+    egrep -q '[^#]*pam_winbind.so' $i && found=1 && break;
+  done
+
+  if [ $found != 0 ]; then
+    # if so, ensure that in /etc/nsswitch.conf we have for
+    # "passwd", "shadow", "group" an entry for "winbind"
+    egrep -q '^passwd:.*winbind' /etc/nsswitch.conf && return 1
+    egrep -q '^shadow:.*winbind' /etc/nsswitch.conf && return 1
+    egrep -q '^group:.*winbind' /etc/nsswitch.conf && return 1 
+  fi
+
+  return 0
+}
+
 case "$1" in
  start)
   [ ! -e $SVIlock ] || exit 0
   [ -x $DAEMON_S -a -x $DAEMON_N ] || exit 5
-  SVIemptyConfig /etc/samba.d/smb.conf && exit 6
+  SVIemptyConfig $config_file && exit 6
 
   echo -n "Starting $SVIsubsys services: "
   ssd -S -n $NAME_S -x $DAEMON_S -- $OPTIONS_SMB
+  WinbdConfig $config_file || ssd -S -n $NAME_W -x $DAEMON_W -- $OPTIONS_WINBD
   ssd -S -n $NAME_N -x $DAEMON_N -- $OPTIONS_NMB
   ret=$?
 
@@ -55,8 +89,9 @@ case "$1" in
   [ -e $SVIlock ] || exit 0
 
   echo -n "Stopping $SVIsubsys services: "
-  ssd -K -p /var/lock/samba.d/$NAME_N.pid -n $NAME_N #-x $DAEMON_N
   ssd -K -p /var/lock/samba.d/$NAME_S.pid -n $NAME_S #-x $DAEMON_S
+  ssd -K -p /var/lock/samba.d/$NAME_W.pid -n $NAME_W #-x $DAEMON_W
+  ssd -K -p /var/lock/samba.d/$NAME_N.pid -n $NAME_N #-x $DAEMON_N
 
   ret=$?
 
@@ -73,6 +108,8 @@ case "$1" in
  reload)
   echo -n "Reloading $SVIsubsys service configuration: "
   # nmbd has no config file to reload
+  ssd -K --signal 1 -p /var/lock/samba.d/$NAME_N.pid -n $NAME_N #-x $DAEMON_N
+  ssd -K --signal 1 -p /var/lock/samba.d/$NAME_W.pid -n $NAME_W #-x $DAEMON_W
   ssd -K --signal 1 -p /var/lock/samba.d/$NAME_S.pid -n $NAME_S #-x $DAEMON_S
   ret=$?
   echo  "."