~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/p3scan

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
#
 
3
### BEGIN INIT INFO
 
4
# Provides:          p3scan
 
5
# Required-Start:    $remote_fs $syslog
 
6
# Required-Stop:     $remote_fs $syslog
 
7
# Default-Start:     2 3 4 5
 
8
# Default-Stop:      0 1 6
 
9
### END INIT INFO
 
10
#
 
11
#   Written by Miquel van Smoorenburg <miquels@cistron.nl>.
 
12
#   Modified for Debian by Ian Murdock <imurdock@gnu.ai.mit.edu>.
 
13
#   Modified for p3scan by Mats Rynge <mats@rynge.net>
 
14
#
 
15
 
 
16
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
17
DAEMON=/usr/sbin/p3scan
 
18
NAME=p3scan
 
19
DESC="transparent pop3 virus- and spam-scanner"
 
20
PIDFILE=/run/$NAME/$NAME.pid
 
21
 
 
22
test -x $DAEMON || exit 0
 
23
 
 
24
set -e
 
25
 
 
26
# Read config
 
27
DEFAULTFILE=/etc/default/p3scan
 
28
DAEMON_OPTS=
 
29
if [ -f $DEFAULTFILE ]; then
 
30
    . $DEFAULTFILE
 
31
fi
 
32
 
 
33
 
 
34
check_running()
 
35
{
 
36
    start-stop-daemon --test --start --quiet \
 
37
        --pidfile $PIDFILE \
 
38
        --exec $DAEMON -- $DAEMON_OPTS
 
39
    return $?
 
40
}
 
41
 
 
42
 
 
43
case "$1" in
 
44
  start)
 
45
      if check_running; then
 
46
        echo -n "Starting $DESC: "
 
47
        if [ ! -e /run/$NAME ]; then
 
48
            mkdir /run/$NAME
 
49
            chown p3scan: /run/$NAME
 
50
        fi
 
51
        rm -rf /var/spool/p3scan/children/*
 
52
        start-stop-daemon --start --quiet \
 
53
            --pidfile $PIDFILE \
 
54
            --exec $DAEMON -- $DAEMON_OPTS
 
55
        echo "$NAME."
 
56
      else
 
57
        echo "$NAME is already running."
 
58
      fi
 
59
      ;;
 
60
 
 
61
  stop)
 
62
      if check_running; then
 
63
        echo "$NAME is not running."
 
64
        rm -f $PIDFILE
 
65
      else
 
66
        echo -n "Stopping $DESC: "
 
67
        start-stop-daemon --stop --retry 3 --quiet \
 
68
            --pidfile $PIDFILE \
 
69
            --exec $DAEMON || /bin/true
 
70
        echo "$NAME."
 
71
        rm -f $PIDFILE
 
72
      fi
 
73
      ;;
 
74
 
 
75
  restart|force-reload)
 
76
      $0 stop
 
77
      $0 start
 
78
      ;;
 
79
 
 
80
  *)
 
81
      N=/etc/init.d/$NAME
 
82
      echo "Usage: $N {start|stop|restart|force-reload}" >&2
 
83
      exit 1
 
84
      ;;
 
85
 
 
86
esac
 
87
 
 
88
exit 0
 
89