Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
480 franck 1
#!/bin/sh
2
#
3
# $Id: havp-init 480 2011-02-08 22:51:57Z 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
 
29
havp_loopback=/var/lib/havp/havp.loop
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)
70
	        if [ x"$USE_LOOPBACK" = x"true" -a -e $havp_loopback ] && \
71
		   ! [ "`mount | grep ^$havp_loopback`" ]; then
72
			echo -n "Mounting $havp_loopback under $havp_mountpoint ..."
73
			mount  -o rw,mand,loop,noatime,async  $havp_loopback $havp_mountpoint
74
			chown -R havp:havp $havp_mountpoint
75
			echo "done"
76
	        fi
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
		exit $?
87
		;;
88
 
89
	stop)
90
		echo "Shutting down $NAME ..."
91
		if [ ! -f "$PIDFILE" ]; then
92
		  echo "Error: HAVP not running or PIDFILE unreadable"
93
		  exit 1
94
		fi
95
		PID="`cat $PIDFILE`"
96
		if [ "$PID" != "" ]; then
97
			kill -TERM "$PID" >/dev/null 2>&1
98
			if [ $? -ne 0 ]; then
99
				echo "Error: HAVP not running"
100
				exit 1
101
			fi
102
		else
103
			echo "Error: HAVP not running or PIDFILE unreadable"
104
			exit 1
105
		fi
106
		echo -n "Cleaning up $havp_mountpoint"...
107
		find $havp_mountpoint/ -type f -delete
108
		echo " done"
109
 
110
		sleep 2
111
	        if [ x"$USE_LOOPBACK" = x"true" ] && [ "`mount | grep ^$havp_loopback`" ]; then
112
			echo -n "Unmounting $havp_mountpoint ..."
113
			umount $havp_mountpoint
114
			echo "done"
115
	        fi
116
		exit 0
117
		;;
118
 
119
	restart)
120
		echo "Shutting down HAVP ..."
121
		$0 stop >/dev/null 2>&1
122
		$0 start
123
		exit $?
124
		;;
125
 
126
	reload-lists)
127
		reload_havp
128
		;;
129
 
130
	force-reload)
131
		reload_havp
132
		;;
133
 
134
	reload)
135
		reload_havp
136
		;;
137
 
138
	status)
139
		status havp
140
		exit 4
141
		;;
142
 
143
	*)
144
		N=/etc/init.d/$NAME
145
		echo "Usage: $N {start|stop|status|restart|force-reload|reload|reload-lists}"
146
		exit 0
147
		;;
148
esac
149
 
150
exit 0