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
18
PIDFILE=/var/run/havp/havp.pid
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
89
		exit $?
90
		;;
91
 
92
	stop)
93
		echo "Shutting down $NAME ..."
94
		if [ ! -f "$PIDFILE" ]; then
95
		  echo "Error: HAVP not running or PIDFILE unreadable"
96
		  exit 1
97
		fi
98
		PID="`cat $PIDFILE`"
99
		if [ "$PID" != "" ]; then
100
			kill -TERM "$PID" >/dev/null 2>&1
101
			if [ $? -ne 0 ]; then
102
				echo "Error: HAVP not running"
103
				exit 1
104
			fi
105
		else
106
			echo "Error: HAVP not running or PIDFILE unreadable"
107
			exit 1
108
		fi
1005 richard 109
	        if [ "`mount | grep $havp_mountpoint`" ]; then
110
			echo -n "Cleaning up $havp_mountpoint"...
111
			find $havp_mountpoint/ -type f -delete
112
			echo " done"
480 franck 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