Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
480 franck 1
#!/bin/sh
2
#
482 franck 3
#
480 franck 4
####
5
# This init-script tries to be LSB conform but platform independent.
6
# 
7
# Therefore check the following two variables to fit to your requests:
8
# HAVP_BIN HAVP_CONFIG PIDFILE
9
# Any configuration of HAVP is done in havp.config
10
# Type havp --help for help and read havp.config you should have received.
11
# chkconfig: 2345 11 89
12
# description: starts HAVP the High Availability Antivirus Proxy
13
#
14
 
15
. /etc/init.d/functions
16
HAVP_BIN=/usr/sbin/havp
17
HAVP_CONFIG=/etc/havp/havp.config
2776 rexy 18
PIDFILE=/run/havp/havp.pid
480 franck 19
NAME=havp
20
DESC=havp
21
 
22
test -x $HAVP_BIN || exit 0
23
 
24
# Include havp defaults if available
25
if [ -f /etc/sysconfig/havp ] ; then
26
	. /etc/sysconfig/havp
27
fi
28
 
482 franck 29
havp_loopback=tmpfs
480 franck 30
havp_mountpoint=/var/tmp/havp
31
 
32
#set -e
33
 
34
# Return values acc. to LSB for all commands but status:
35
# 1       generic or unspecified error (current practice)
36
# 2       invalid or excess argument(s)
37
# 3       unimplemented feature (for example, "reload")
38
# 4       user had insufficient privilege
39
# 5       program is not installed
40
# 6       program is not configured
41
# 7       program is not running
42
# 8-99    reserved for future LSB use
43
# 100-149 reserved for distribution use
44
# 150-199 reserved for application use
45
# 200-254 reserved
46
# Note that starting an already running service, stopping
47
# or restarting a not-running service as well as the restart
48
# with force-reload (in case signaling is not supported) are
49
# considered a success.
50
 
51
reload_havp()
52
{
53
	echo "Reloading HAVP ..."
54
	PID="`cat $PIDFILE`"
55
	if [ "$PID" != "" ]; then
56
		kill -HUP "$PID" >/dev/null 2>&1
57
		if [ $? -ne 0 ]; then
58
			echo "Error: HAVP not running"
59
			exit 1
60
		fi
61
	else
62
		echo "Error: HAVP not running or PIDFILE not readable"
63
		exit 1
64
	fi
65
	exit 0
66
}
67
 
68
case "$1" in
69
	start)
1005 richard 70
	        if ! [ "`mount | grep $havp_mountpoint`" ]; then
480 franck 71
			echo -n "Mounting $havp_loopback under $havp_mountpoint ..."
482 franck 72
			mount -t tmpfs -o mand,noatime,size=50m,nosuid,noexec $havp_loopback $havp_mountpoint
480 franck 73
			chown -R havp:havp $havp_mountpoint
74
			echo "done"
75
	        fi
1005 richard 76
	        if [ "`mount | grep $havp_mountpoint`" ]; then
77
			echo -n "Cleaning up $havp_mountpoint"...
78
			find $havp_mountpoint/ -type f -delete
79
			echo " done"
80
			echo -n "Starting $DESC: "
81
			if [ ! -f $HAVP_BIN ]; then
82
				echo "Error: $HAVP_BIN not found"
83
				exit 5
84
			fi
85
			$HAVP_BIN -c $HAVP_CONFIG
86
		else
87
		       echo "Error: mount tmpfs point failed"
480 franck 88
		fi
1192 crox53 89
		chmod 644 /var/log/havp/access.log
480 franck 90
		exit $?
91
		;;
92
 
93
	stop)
94
		echo "Shutting down $NAME ..."
95
		if [ ! -f "$PIDFILE" ]; then
96
		  echo "Error: HAVP not running or PIDFILE unreadable"
97
		  exit 1
98
		fi
99
		PID="`cat $PIDFILE`"
100
		if [ "$PID" != "" ]; then
101
			kill -TERM "$PID" >/dev/null 2>&1
102
			if [ $? -ne 0 ]; then
103
				echo "Error: HAVP not running"
104
				exit 1
105
			fi
106
		else
107
			echo "Error: HAVP not running or PIDFILE unreadable"
108
			exit 1
109
		fi
1005 richard 110
	        if [ "`mount | grep $havp_mountpoint`" ]; then
111
			echo -n "Cleaning up $havp_mountpoint"...
112
			find $havp_mountpoint/ -type f -delete
113
			echo " done"
480 franck 114
			echo -n "Unmounting $havp_mountpoint ..."
115
			umount $havp_mountpoint
116
			echo "done"
117
	        fi
118
		exit 0
119
		;;
120
 
121
	restart)
122
		echo "Shutting down HAVP ..."
123
		$0 stop >/dev/null 2>&1
124
		$0 start
125
		exit $?
126
		;;
127
 
128
	reload-lists)
129
		reload_havp
130
		;;
131
 
132
	force-reload)
133
		reload_havp
134
		;;
135
 
136
	reload)
137
		reload_havp
138
		;;
139
 
140
	status)
141
		status havp
142
		exit 4
143
		;;
144
 
145
	*)
146
		N=/etc/init.d/$NAME
147
		echo "Usage: $N {start|stop|status|restart|force-reload|reload|reload-lists}"
148
		exit 0
149
		;;
150
esac
151
 
152
exit 0