aboutsummaryrefslogtreecommitdiff
path: root/network/wsdd2/rc.wsdd2
blob: 594e1faab537220fe06ca16b1a7f40944866366d (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
#!/bin/sh
#
# /etc/rc.d/rc.wsdd2
#
# start/stop/restart the wsdd2 daemon.
#
# To make wsdd2 start automatically at boot make sure this
# file is executable, and add the following entry to rc.local
# after the samba test (uncommented)

# if [ -x /etc/rc.d/rc.wsdd2 ]; then
#   /etc/rc.d/rc.wsdd2 start
# fi

# you may also add the following entry to rc.local_shutdown
# (uncommented)

# if [ -x /etc/rc.d/rc.wsdd2 ]; then
#   /etc/rc.d/rc.wsdd2 stop
# fi

wsdd2_start() {
  if [ -r /etc/samba/smb.conf -a -x /etc/rc.d/rc.samba -a -x /usr/sbin/wsdd2 ]; then
    echo "Starting wsdd2: /usr/bin/wsdd2 -d"
    /usr/sbin/wsdd2 -d
  elif [ ! -r /etc/samba/smb.conf ]; then
    echo "ERROR: samba not configured, so wsdd2 has no service to advertise"
  fi
}
wsdd2_stop() {
  #check something is running before trying to kill it.
  if [ "x`ps -A|grep ' wsdd2'|wc -l`" != "x0" ]; then
    killall wsdd2
  fi
}
wsdd2_restart() {
  wsdd2_stop
  sleep 1
  wsdd2_start
}
case "$1" in
'start')
  #we don't want to run this more than once,
  #so kill off any instance already running
  wsdd2_stop
  wsdd2_start
  ;;
'stop')
  wsdd2_stop
  ;;
'restart')
  wsdd2_restart
  ;;
*)
  # default is start
  wsdd2_start
esac