Subversion Repositories ALCASAR

Rev

Rev 480 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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