summaryrefslogtreecommitdiff
path: root/packaging/Caldera/OpenLinux/samba.init-lsb
blob: f14eef648faf8318947c5e27c73ba17e252b541c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#
#
### BEGIN INIT INFO
# Provides: $samba
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: samba
#		Starts and stops the Samba smbd and nmbd daemons
#		used to provide SMB network services.
### END INIT INFO
#
# Written by Miquel van Smoorenburg <miquels@drinkel.ow.org>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for OpenLinux by Raymund Will <ray@caldera.de>
# Adapted for samba by Klaus Singvogel <klaus@caldera.de>

NAME_S=smbd
DAEMON_S=/usr/sbin/$NAME_S
NAME_N=nmbd
DAEMON_N=/usr/sbin/$NAME_N

# Source function library (and set vital variables).
.  @SVIdir@/functions

status() {
  [ -e $1 ] || return 3; # lock / pid file doesn't exist, seems to be stopped
  
  i=`cat "$1"`
  state=`egrep '^State' /proc/$i/status 2>/dev/null| sed 's#.*	\(.\).*#\1#'`
  if [ x$state = x -o x$state = xZ ]; then
    return 2             # no such process (or zombie) --> dead
  fi
  return 0               # seems to be up and running
}

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

  echo -n "Starting $SVIsubsys services: "
  ssd -S -n $NAME_S -x $DAEMON_S -- $OPTIONS_SMB
  ssd -S -n $NAME_N -x $DAEMON_N -- $OPTIONS_NMB
  ret=$?

  echo  "."
  touch $SVIlock
  ;;

 stop)
  [ -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

  ret=$?

  echo "."
  rm -f $SVIlock
  ;;

 force-reload)
  [ -e $SVIlock ] || exit 0
  $0 restart
  ret=$?
  ;;

 reload)
  echo -n "Reloading $SVIsubsys service configuration: "
  # nmbd has no config file to reload
  ssd -K --signal 1 -p /var/lock/samba.d/$NAME_S.pid -n $NAME_S #-x $DAEMON_S
  ret=$?
  echo  "."
  ;;

 restart)
  $0 stop
  $0 start
  ret=$?
  ;;

 status)
  echo -n "Checking status of $SVIsubsys service: "
  status /var/lock/samba.d/$NAME_N.pid
  ret=$?
  if [ $ret -eq 0 ]; then
    echo -n "$NAME_N "
    status /var/lock/samba.d/$NAME_S.pid
    ret=$?
    [ $ret -eq 0 ] && echo -n "$NAME_S"
  fi
  echo "."
  ;;

 *)
  echo "Usage: $SVIscript {start|stop|restart|force-reload|reload|status}"
  ret=2
  ;;

esac

exit $ret