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