~ubuntu-branches/ubuntu/lucid/eucalyptus/lucid

108 by Dustin Kirkland
* clc/modules/www/src/main/java/edu/ucsb/eucalyptus/admin/client/EucalyptusWebInterface.java:
1
# eucalyptus-cc
2
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
3
description "Eucalyptus cluster controller"
4
author "Matt Zimmerman <mdz@canonical.com>"
5
88 by Thierry Carrez
* tools/euca_conf.in: Fix euca_conf local key sync regression (LP: #499811)
6
start on started eucalyptus
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
7
stop on stopping eucalyptus
8
9
# These must be set in the apache2 environment -mdz
10
env HTTPD_CONF=/var/run/eucalyptus/httpd-cc.conf
11
env EUCALYPTUS=/
12
env AXIS2C_HOME=/etc/eucalyptus/axis2
13
14
pre-start script
15
	# clean up semaphores
16
	rm -f /dev/shm/*eucalyptusCC*
76 by Dustin Kirkland
* debian/patches/06-symlinked-jars.patch: drop patch from source; this
17
	[ "${CLEAN}" = 1 ] && rm -f /var/lib/eucalyptus/CC/*
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
18
19
	# Enable IP forwarding
20
	sysctl -w net.ipv4.ip_forward=1
21
56 by Dustin Kirkland
* eucalyptus-cc.upstart, eucalyptus-common.eucalyptus.upstart: ensure
22
	mkdir -p /var/run/eucalyptus/net
23
	chown eucalyptus:eucalyptus /var/run/eucalyptus /var/run/eucalyptus/net
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
24
25
	. /etc/eucalyptus/eucalyptus.conf
97 by Dustin Kirkland, Mathias Gug, Dustin Kirkland
[ Mathias Gug ]
26
	. /etc/eucalyptus/eucalyptus.local.conf
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
27
28
	# Generate httpd.conf
29
	AXIS2C_HOME=/etc/eucalyptus/axis2
30
	ALLOWED_IPS="all"
31
	HTTPD_HOME="/"
32
	tmp=$(tempfile)
33
34
        # let's configure the common parts for both CC and NC
35
        cat $EUCALYPTUS/etc/eucalyptus/httpd.conf |sed "s|EUCALYPTUS|$EUCALYPTUS|"|sed "s|AXIS2C_HOME|$AXIS2C_HOME|"|sed "s|\(ServerRoot\).*|\1 "$HTTPD_HOME"|" |sed "s|EUCA_USER|$EUCA_USER|" >> $tmp
36
37
        # if we find authz load it (needed by ubuntu)
38
        if [ -e $HTTPD_HOME/usr/lib/apache2/modules/mod_authz_host.so ]; then
39
                echo "LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so" >> $tmp
40
        fi
41
42
        # let's configure the CC
59 by Dustin Kirkland, Thierry Carrez, Dustin Kirkland
[ Thierry Carrez ]
43
        cat $tmp |sed "s|\(Listen\).*|\1 $CC_PORT|"|sed "s|\(PidFile\).*|\1 $EUCALYPTUS/var/run/eucalyptus/eucalyptus-cc.pid|"|sed "s|\(Allow from\).*|\1 $ALLOWED_IPS|"|sed "s|\(ErrorLog\).*|\1 $EUCALYPTUS/var/log/eucalyptus/httpd-cc_error_log|"|sed "s|\(StartServers\).*|\1 5|"|sed "s|\(MinSpareServers\).*|\1 5|"|sed "s|\(MaxSpareServers\).*|\1 10|"|sed "s|\(MaxClients\).*|\1 8|" |sed "s|\(MinSpareThreads\).*|\1 25|" | sed "s|\(MaxSpareThreads\).*|\1 75|" | sed "s|\(ThreadsPerChild\).*|\1 1|" | sed "s|\(ThreadLimit\).*|\1 64|" >  $HTTPD_CONF
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
44
45
        cat >>$HTTPD_CONF <<EOF
46
LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
80 by Colin Watson
* Generate a preseed file on the CLC as well as the CC.
47
Alias /preseed/preseed.conf /etc/eucalyptus/preseed/preseed.conf
48
# Compatibility with Ubuntu 9.10.
49
Alias /node-preseed /etc/eucalyptus/preseed/preseed.conf
50
<Files /etc/eucalyptus/preseed/preseed.conf>
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
51
    Order allow,deny
52
    Allow from all
53
</Files>
54
EOF
55
56
end script
57
58
exec apache2 -f /var/run/eucalyptus/httpd-cc.conf -D FOREGROUND
59
60
post-start script
61
	timeout=60
62
	while [ $timeout -gt 0 ]; do
60 by Dustin Kirkland
* Merge upstream revision 916
63
		. /etc/eucalyptus/eucalyptus-ipaddr.conf
59 by Dustin Kirkland, Thierry Carrez, Dustin Kirkland
[ Thierry Carrez ]
64
		if wget -q -T10 -t1 -O- http://$CC_IP_ADDR:8774/axis2/services/ | \
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
65
			grep EucalyptusCC; then
66
86 by Thierry Carrez
* debian/*publication.upstart: Do not use IP address as Avahi service name,
67
			# It's alive! Start uec-component-listener if no CLC
68
			if [ ! -f /usr/share/eucalyptus/eucalyptus-cloud-1.6.2.jar ]; then
69
				initctl start uec-component-listener
70
			fi
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
71
			exit 0
72
		fi
60 by Dustin Kirkland
* Merge upstream revision 916
73
		sleep 2
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
74
		timeout=$(($timeout-1))
75
	done
60 by Dustin Kirkland
* Merge upstream revision 916
76
	stop
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
77
	exit 1
78
end script
79
80
post-stop script
81
	# clean up semaphores
82
	rm -f /dev/shm/*eucalyptusCC*
76 by Dustin Kirkland
* debian/patches/06-symlinked-jars.patch: drop patch from source; this
83
	[ "${CLEAN}" = 1 ] && rm -f /var/lib/eucalyptus/CC/*
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
84
85
	# kill vtund processes
63 by Thierry Carrez, Matt Zimmerman, Thierry Carrez
[ Matt Zimmerman ]
86
	for pidfile in /var/run/eucalyptus/vtund*.pid \
87
		/var/run/eucalyptus/net/euca-dhcp.pid; do
88
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
89
		if [ -s $pidfile ]; then
90
			pid=$(cat $pidfile)
91
			timeout=5
92
			while [ $timeout -gt 0 ] && ps $pid >/dev/null; do
93
				kill $pid
94
				sleep 1
57 by Dustin Kirkland
* eucalyptus-common.eucalyptus.upstart: the -L option was in the wrong
95
				timeout=$(($timeout-1))
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
96
			done
97
		fi
98
	done
75 by Dustin Kirkland, Dustin Kirkland
[ Dustin Kirkland ]
99
100
	rm -f /var/lib/eucalyptus/CC/*
53 by Matt Zimmerman, Colin Watson, Matt Zimmerman
[ Colin Watson ]
101
end script