File: pysrs.rc

package info (click to toggle)
pysrs 1.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 280 kB
  • sloc: python: 1,288; sh: 72; makefile: 23
file content (94 lines) | stat: -rwxr-xr-x 1,849 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
#
# pysrs	This shell script takes care of starting and stopping pysrs.
#
# chkconfig: 2345 80 30
# description: Milter is a process that filters messages sent through sendmail.
# processname: pysrs
# config: /etc/mail/pysrs.cfg
# pidfile: /var/run/milter/pysrs.pid

python="python"

pidof() {
	set - ""
	if set - `ps -e -o pid,cmd | grep "${python} pysrs.py"` &&
	  [ "$2" != "grep" ]; then
	  echo $1
	  return 0
	fi
	return 1
}

# Source function library.
. /etc/rc.d/init.d/functions

test -x /usr/lib/pymilter/pysrs.py && test -x /usr/sbin/daemonize || exit 0

RETVAL=0
prog="pysrs"
datadir="/var/log/milter"
logdir="/var/log/milter"
piddir="/var/run/milter"
libdir="/usr/lib/pymilter"

start() {
	# Start daemon.
	if test -s ${datadir}/${prog}.py; then
	  workdir="${datadir}" # use data dir if it exists for debugging
	elif test -s ${logdir}/${prog}.py; then
	  workdir="${logdir}" # use log dir if it exists for debugging
	else
	  workdir="${libdir}"
	fi
	echo -n "Starting $prog: "
	daemon --check pysrs --pidfile "${piddir}/${prog}.pid" --user mail \
	daemonize -a -e "${logdir}/${prog}.log" -o "${logdir}/${prog}.log" \
		-c "${workdir}" -p "${piddir}/${prog}.pid" \
		/usr/bin/${python} ${prog}.py 
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pysrs
	return $RETVAL
}

stop() {
	# Stop daemons.
	echo -n "Shutting down $prog: "
	killproc -p "${piddir}/${prog}.pid" pysrs
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pysrs
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
	start
	RETVAL=$?
	;;
  condrestart)
	if [ -f /var/lock/subsys/pysrs ]; then
	    stop
	    start
	    RETVAL=$?
	fi
	;;
  status)
	status pysrs
	RETVAL=$?
	;;
  *)
	echo "Usage: $0 {start|stop|restart|condrestart|status}"
	exit 1
esac

exit $RETVAL