Subversion Repositories ALCASAR

Rev

Rev 482 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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