f14eef648faf8318947c5e27c73ba17e252b541c
[kai/samba.git] / packaging / Caldera / OpenLinux / samba.init-lsb
1 #!/bin/bash
2 #
3 #
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
14 #
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>
19
20 NAME_S=smbd
21 DAEMON_S=/usr/sbin/$NAME_S
22 NAME_N=nmbd
23 DAEMON_N=/usr/sbin/$NAME_N
24
25 # Source function library (and set vital variables).
26 .  @SVIdir@/functions
27
28 status() {
29   [ -e $1 ] || return 3; # lock / pid file doesn't exist, seems to be stopped
30   
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
35   fi
36   return 0               # seems to be up and running
37 }
38
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
44
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=$?
49
50   echo  "."
51   touch $SVIlock
52   ;;
53
54  stop)
55   [ -e $SVIlock ] || exit 0
56
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
60
61   ret=$?
62
63   echo "."
64   rm -f $SVIlock
65   ;;
66
67  force-reload)
68   [ -e $SVIlock ] || exit 0
69   $0 restart
70   ret=$?
71   ;;
72
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  "."
79   ;;
80
81  restart)
82   $0 stop
83   $0 start
84   ret=$?
85   ;;
86
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"
96   fi
97   echo "."
98   ;;
99
100  *)
101   echo "Usage: $SVIscript {start|stop|restart|force-reload|reload|status}"
102   ret=2
103   ;;
104
105 esac
106
107 exit $ret
108