Subversion Repositories ALCASAR

Rev

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

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