forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevcloudsetup.sh
More file actions
151 lines (128 loc) · 5.02 KB
/
devcloudsetup.sh
File metadata and controls
151 lines (128 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
fileSvr="http://download.cloud.com/templates/devcloud/"
install_xen() {
aptitude update
echo "install xen"
aptitude -y install linux-headers-3.2.0-23-generic-pae
aptitude -y install xen-hypervisor-4.1-i386 xcp-xapi
echo "configure xen"
sed -i -e 's/xend_start$/#xend_start/' -e 's/xend_stop$/#xend_stop/' /etc/init.d/xend
update-rc.d xendomains disable
sed -i 's/GRUB_DEFAULT=.\+/GRUB_DEFAULT="Xen 4.1-i386"/' /etc/default/grub
echo 'GRUB_CMDLINE_XEN_DEFAULT="dom0_mem=512M,max:512M"' | cat /etc/default/grub - >> /etc/default/newgrub
mv /etc/default/newgrub /etc/default/grub
update-grub
mkdir /usr/share/qemu
ln -s /usr/share/qemu-linaro/keymaps /usr/share/qemu/keymaps
cat > /etc/network/interfaces << EOF
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto xenbr0
iface xenbr0 inet dhcp
gateway 10.0.2.2
bridge_ports eth0
auto eth0
iface eth0 inet dhcp
pre-up iptables-save < /etc/iptables.save
pre-up /etc/init.d/ebtables load
EOF
echo TOOLSTACK=xapi > /etc/default/xen
echo bridge > /etc/xcp/network.conf
echo "set root password"
echo "root:password" | chpasswd
echo "reboot"
reboot
}
postsetup() {
#check xen dom0 is working
xe host-list > /dev/null
if [ $? -gt 0 ]; then
print "xen dom0 is not running, make sure dom0 is installed"
exit 1
fi
#disable virtualbox dhcp server for Vms created by cloudstack
apt-get install ebtables
iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill
mac=`ifconfig xenbr0 |grep HWaddr |awk '{print $5}'`
ebtables -I FORWARD -d ! $mac -i eth0 -p IPV4 --ip-prot udp --ip-dport 67:68 -j DROP
iptables-save > /etc/iptables.save
/etc/init.d/ebtables save
echo "configure NFS server"
aptitude -y install nfs-server
if [ ! -d /opt/storage/secondary ];then
mkdir -p /opt/storage/secondary
mkdir -p /opt/storage/secondary/template/tmpl/1/1
mkdir -p /opt/storage/secondary/template/tmpl/1/5
echo "/opt/storage/secondary *(rw,no_subtree_check,no_root_squash,fsid=0)" > /etc/exports
wget $fileSvr/defaulttemplates/1/dc68eb4c-228c-4a78-84fa-b80ae178fbfd.vhd -P /opt/storage/secondary/template/tmpl/1/1/
wget $fileSvr/defaulttemplates/1/template.properties -P /opt/storage/secondary/template/tmpl/1/1/
wget $fileSvr/defaulttemplates/5/ce5b212e-215a-3461-94fb-814a635b2215.vhd -P /opt/storage/secondary/template/tmpl/1/5/
wget $fileSvr/defaulttemplates/5/template.properties -P /opt/storage/secondary/template/tmpl/1/5/
/etc/init.d/nfs-kernel-server restart
fi
echo "configure local storage"
if [ ! -d /opt/storage/primary ]; then
mkdir -p /opt/storage/primary
hostuuid=`xe host-list |grep uuid|awk '{print $5}'`
xe sr-create host-uuid=$hostuuid name-label=local-storage shared=false type=file device-config:location=/opt/storage/primary
fi
echo "generate ssh key"
ssh-keygen -A -q
echo "configure xcp"
wget $fileSvr/echo -P /usr/lib/xcp/plugins/
chmod -R 777 /usr/lib/xcp
sed -i 's/VNCTERM_LISTEN=.\+/VNCTERM_LISTEN="-v 0.0.0.0:1"/' /usr/lib/xcp/lib/vncterm-wrapper
echo "install cloudstack "
if [ ! -d /opt/cloudstack ];then
aptitude -y install git unzip openjdk-6-jdk mysql-server ant
mkdir /opt/cloudstack
cd /opt/cloudstack
git clone https://git-wip-us.apache.org/repos/asf/incubator-cloudstack.git
mkdir incubator-cloudstack/target
mkdir incubator-cloudstack/dist
wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.zip -P /opt/cloudstack/
unzip apache-tomcat-6.0.32.zip
echo "export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32" >> /root/.bashrc
cd ~
fi
echo "devCloud is ready to use"
}
usage() {
print "$0 -p: presetup enviroment, e.g. install xen, configure xcp etc"
print "$0 -P: postsetup, install cloudstack, prepare template etc"
}
while getopts "pP" OPTION
do
case $OPTION in
p)
install_xen
exit 0
;;
P)
postsetup
exit 0
;;
?)
usage
exit
;;
esac
done