more syncs with SAMBA_2_2
[Samba/gbeck.git] / packaging / Caldera / OpenLinux / samba.init-lsb
blobf14eef648faf8318947c5e27c73ba17e252b541c
1 #!/bin/bash
4 ### BEGIN INIT INFO
5 # Provides: $samba
6 # Required-Start: $network
7 # Required-Stop: $network
8 # Default-Start: 2 3 4 5
9 # Default-Stop: 0 1 6
10 # Description: samba
11 # Starts and stops the Samba smbd and nmbd daemons
12 # used to provide SMB network services.
13 ### END INIT INFO
15 # Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
16 # Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
17 # Modified for OpenLinux by Raymund Will <ray@caldera.de>
18 # Adapted for samba by Klaus Singvogel <klaus@caldera.de>
20 NAME_S=smbd
21 DAEMON_S=/usr/sbin/$NAME_S
22 NAME_N=nmbd
23 DAEMON_N=/usr/sbin/$NAME_N
25 # Source function library (and set vital variables).
26 . @SVIdir@/functions
28 status() {
29 [ -e $1 ] || return 3; # lock / pid file doesn't exist, seems to be stopped
31 i=`cat "$1"`
32 state=`egrep '^State' /proc/$i/status 2>/dev/null| sed 's#.* \(.\).*#\1#'`
33 if [ x$state = x -o x$state = xZ ]; then
34 return 2 # no such process (or zombie) --> dead
36 return 0 # seems to be up and running
39 case "$1" in
40 start)
41 [ ! -e $SVIlock ] || exit 0
42 [ -x $DAEMON_S -a -x $DAEMON_N ] || exit 5
43 SVIemptyConfig /etc/samba.d/smb.conf && exit 6
45 echo -n "Starting $SVIsubsys services: "
46 ssd -S -n $NAME_S -x $DAEMON_S -- $OPTIONS_SMB
47 ssd -S -n $NAME_N -x $DAEMON_N -- $OPTIONS_NMB
48 ret=$?
50 echo "."
51 touch $SVIlock
54 stop)
55 [ -e $SVIlock ] || exit 0
57 echo -n "Stopping $SVIsubsys services: "
58 ssd -K -p /var/lock/samba.d/$NAME_N.pid -n $NAME_N #-x $DAEMON_N
59 ssd -K -p /var/lock/samba.d/$NAME_S.pid -n $NAME_S #-x $DAEMON_S
61 ret=$?
63 echo "."
64 rm -f $SVIlock
67 force-reload)
68 [ -e $SVIlock ] || exit 0
69 $0 restart
70 ret=$?
73 reload)
74 echo -n "Reloading $SVIsubsys service configuration: "
75 # nmbd has no config file to reload
76 ssd -K --signal 1 -p /var/lock/samba.d/$NAME_S.pid -n $NAME_S #-x $DAEMON_S
77 ret=$?
78 echo "."
81 restart)
82 $0 stop
83 $0 start
84 ret=$?
87 status)
88 echo -n "Checking status of $SVIsubsys service: "
89 status /var/lock/samba.d/$NAME_N.pid
90 ret=$?
91 if [ $ret -eq 0 ]; then
92 echo -n "$NAME_N "
93 status /var/lock/samba.d/$NAME_S.pid
94 ret=$?
95 [ $ret -eq 0 ] && echo -n "$NAME_S"
97 echo "."
101 echo "Usage: $SVIscript {start|stop|restart|force-reload|reload|status}"
102 ret=2
105 esac
107 exit $ret