summaryrefslogtreecommitdiff
path: root/community/p3scan/rc.p3scan
blob: fc8b79b223539a621c07b2051ec180c9bdc4c273 (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
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting p3scan"
    [ -d /var/run/p3scan ] || mkdir -p /var/run/p3scan
    if [ -a /var/run/p3scan/p3scan.pid ]; then stat_die; fi

    # Start p3scan
    /usr/sbin/p3scan    
    if ! [ -a /var/run/p3scan/p3scan.pid ]; then stat_die; fi
    add_daemon p3scan
    stat_done
  ;;
  stop)
    stat_busy "Stopping p3scan"

    # Stop p3scan
    if [ -a /var/run/p3scan/p3scan.pid ]; then
      kill `cat /var/run/p3scan/p3scan.pid` &>/dev/null || stat_die
      rm -f /var/run/p3scan/p3scan.pid
      rm_daemon p3scan
      stat_done
    else
      stat_fail
    fi
  ;;
  restart)
    $0 stop
    sleep 1
    $0 start
  ;;
  *)
    echo "Usage: $0 { start | stop | restart }"
esac
exit 0