summaryrefslogtreecommitdiff
path: root/patches/source/samba/rc.samba
blob: 5b98b879c6dc17b776751805df8f4199e6f9175d (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
#!/bin/sh
#
# /etc/rc.d/rc.samba
#
# Start/stop/restart the Samba SMB file/print server.
#
# To make Samba start automatically at boot, make this
# file executable:  chmod 755 /etc/rc.d/rc.samba
#

samba_start() {
  if [ -x /usr/sbin/smbd -a -x /usr/sbin/nmbd -a -r /etc/samba/smb.conf ]; then
    mkdir -p /var/run/samba
    echo "Starting Samba:  /usr/sbin/smbd -D"
    /usr/sbin/smbd -D
    echo "                 /usr/sbin/nmbd -D"
    /usr/sbin/nmbd -D
  elif [ ! -r /etc/samba/smb.conf ]; then
    echo "ERROR:  cannot start Samba since /etc/samba/smb.conf does not exist"
  fi
}

samba_stop() {
  killall smbd nmbd
}

samba_restart() {
  samba_stop
  sleep 2
  samba_start
}

case "$1" in
'start')
  samba_start
  ;;
'stop')
  samba_stop
  ;;
'restart')
  samba_restart
  ;;
*)
  # Default is "start", for backwards compatibility with previous
  # Slackware versions.  This may change to a 'usage' error someday.
  samba_start
esac