Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
77 richard 1
#!/bin/sh
2
#
3
#
4
####
5
# This init-script tries to be LSB conform but platform independent.
6
# chkconfig: 2345 80 30
7
# description: HAVP (HTTP Antivirus Proxy) is a proxy \
8
#              with a ClamAV anti-virus scanner.
9
# 
10
# Therefore check the following two variables to fit to your requests:
11
# HAVP_BIN HAVP_CONFIG PIDFILE
12
# Any configuration of HAVP is done in havp.config
13
# Type havp --help for help and read havp.config you should have received.
14
 
15
HAVP_BIN=/usr/local/sbin/havp
16
HAVP_CONFIG=/usr/local/etc/havp/havp.config
17
PIDFILE=/var/run/havp/havp.pid
18
 
19
# Return values acc. to LSB for all commands but status:
20
# 1       generic or unspecified error (current practice)
21
# 2       invalid or excess argument(s)
22
# 3       unimplemented feature (for example, "reload")
23
# 4       user had insufficient privilege
24
# 5       program is not installed
25
# 6       program is not configured
26
# 7       program is not running
27
# 8-99    reserved for future LSB use
28
# 100-149 reserved for distribution use
29
# 150-199 reserved for application use
30
# 200-254 reserved
31
# Note that starting an already running service, stopping
32
# or restarting a not-running service as well as the restart
33
# with force-reload (in case signaling is not supported) are
34
# considered a success.
35
 
36
reload_havp()
37
{
38
	echo "Reloading HAVP ..."
39
	PID="`cat $PIDFILE`"
40
	if [ "$PID" != "" ]; then
41
		kill -HUP "$PID" >/dev/null 2>&1
42
		if [ $? -ne 0 ]; then
43
			echo "Error: HAVP not running"
44
			exit 1
45
		fi
46
	else
47
		echo "Error: HAVP not running or PIDFILE not readable"
48
		exit 1
49
	fi
50
	exit 0
51
}
52
 
53
case "$1" in
54
	start)
55
		echo "Starting HAVP ..."
56
		if [ ! -f $HAVP_BIN ]; then
57
			echo "Error: $HAVP_BIN not found"
58
			exit 5
59
		fi
60
		$HAVP_BIN -c $HAVP_CONFIG
61
		exit $?
62
		;;
63
 
64
	stop)
65
		echo "Shutting down HAVP ..."
66
		if [ ! -f "$PIDFILE" ]; then
67
		  echo "Error: HAVP not running or PIDFILE unreadable"
68
		  exit 1
69
		fi
70
		PID="`cat $PIDFILE`"
71
		if [ "$PID" != "" ]; then
72
			kill -TERM "$PID" >/dev/null 2>&1
73
			if [ $? -ne 0 ]; then
74
				echo "Error: HAVP not running"
75
				exit 1
76
			fi
77
		else
78
			echo "Error: HAVP not running or PIDFILE unreadable"
79
			exit 1
80
		fi
81
		sleep 2
82
		exit 0
83
		;;
84
 
85
	restart)
86
		echo "Shutting down HAVP ..."
87
		$0 stop >/dev/null 2>&1
88
		$0 start
89
		exit $?
90
		;;
91
 
92
	reload-lists)
93
		reload_havp
94
		;;
95
 
96
	force-reload)
97
		reload_havp
98
		;;
99
 
100
	reload)
101
		reload_havp
102
		;;
103
 
104
	status)
105
		echo "Checking for service HAVP ..."
106
		exit 4
107
		;;
108
 
109
	*)
110
		echo "Usage: $0 {start|stop|status|restart|force-reload|reload|reload-lists}"
111
		exit 0
112
		;;
113
esac