aboutsummaryrefslogtreecommitdiff
path: root/network/amavisd-new/rc.amavisd-new
blob: 3410eb18c26e19b729f7a001d54b7aca9f3126d9 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh

# Startup script for amavisd-new daemon for use on Slackware Linux x86|x86_64

# Copyright (c) 2008-2012, Nishant Limbachia, Hoffman Estates, IL, USA
# [nishant _AT_ mnspace _DOT_ net]
# Usage: /etc/rc.d/rc.amavisd-new start|stop|restart|reload|status
# For automatic startup at boot, call this script from rc.local

PIDFILE=/var/run/amavis/amavisd.pid

amavisd_start() {
  if [ -x /etc/rc.d/rc.amavisd-new ]; then
	# start amavisd-signer first
	echo "Starting amavisd-signer daemon"
	/usr/sbin/amavisd-signer
	
	if [ -f $PIDFILE ]; then
		echo "amavisd-new daemon running with PID: $(cat $PIDFILE)"
		echo "Or we may have a stale pid file from previous run"
		echo "try /etc/rc.d/rc.amavisd-new stop|restart Or"
		echo "remove the stale pid file and try starting again"
		echo ""
		exit 1
	else
		echo "Starting amavisd-new daemon"
    		/usr/sbin/amavisd-new start
	fi
  fi
}

amavisd_stop() {
	# stop amavisd-signer first
	echo "Stopping amavisd-signer daemon"
	pkill amavisd-signer
	
	if [ -f $PIDFILE ]; then
		echo "Stopping amavisd-new daemon"
		/usr/sbin/amavisd-new stop
	else
		echo "amavisd-new daemon is not running"
	fi
}

amavisd_restart() {
	echo "Restarting amavisd-new daemon"
	/usr/sbin/amavisd-new restart
}

amavisd_reload() {
	echo "Reloading amavisd-new daemon"
	/usr/sbin/amavisd-new reload
}

amavisd_status() {
	echo "amavisd-new daemon running with PID: $(cat $PIDFILE)"
	echo "amavisd-signer daemon running with PID: $(pgrep amavisd-signer)"
}

case "$1" in
'start')
	amavisd_start
  ;;
'stop')
	amavisd_stop
  ;;
'restart')
	amavisd_restart
  ;;
'reload')
	amavisd_reload
  ;;
'status')
	amavisd_status
  ;;
*)
	echo "USAGE: $0 start|stop|restart|reload|status"
	exit 1
  ;;
esac