Subversion Repositories ALCASAR

Rev

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

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