|
2
by Scott Moser
add user-data script for maverick |
1 |
#!/bin/bash |
2 |
# this script expects to be passed in as user-data. Alternatively |
|
3 |
# it could be simply executed. |
|
4 |
# |
|
5 |
# us-east-1 ami-548c783d ebs/ubuntu-maverick-10.10-amd64-server-20101007.1 |
|
6 |
# us-east-1 ami-688c7801 ubuntu-maverick-10.10-amd64-server-20101007.1 |
|
7 |
# if you launch ebs you need to specify |
|
8 |
# --block-device-mapping sdb=ephemeral0 --block-device-mapping sdc=ephemeral1 |
|
9 |
# |
|
10 |
# |
|
11 |
# Launch with user data by: |
|
12 |
# ec2-run-instances ami-688c7801 --instance-type m1.large |
|
13 |
# --user-data-file=uec-on-ec2-userdata.txt |
|
14 |
# |
|
15 |
# At the end of that you should see something like: |
|
16 |
# emi="emi-FDC21818"; eri="eri-53721963"; eki="eki-740D19EC"; |
|
17 |
# |
|
18 |
# then: |
|
19 |
# $ euca-run-instances --key mykey --addressing private emi-FDC21818 |
|
20 |
# and |
|
21 |
# $ ssh -i euca/mykey.pem ubuntu@172.19.1.2 |
|
22 |
||
23 |
set -x |
|
24 |
exec >/home/ubuntu/uec-setup.log 2>&1 |
|
25 |
||
26 |
IFACE=${IFACE:-eth0}
|
|
27 |
# stolen from /etc/eucalyptus/eucalyptus-ipaddr.conf |
|
28 |
addr_withprefix=$(ip addr show label ${IFACE} scope global | awk '$1 == "inet" { print $2 }')
|
|
29 |
IPADDR=${addr_withprefix%%/*}
|
|
30 |
||
31 |
while read tok1 tok2 rest ; do |
|
32 |
[ "${tok1}" = "nameserver" ] && NAMESERVER=${tok2} && break
|
|
33 |
done < /etc/resolv.conf |
|
34 |
||
35 |
cat <<EOF | sudo debconf-set-selections |
|
36 |
postfix postfix/mailname string localhost.localdomain |
|
37 |
postfix postfix/main_mailer_type select Internet Site |
|
38 |
eucalyptus-cc eucalyptus/mode select MANAGED |
|
39 |
eucalyptus-cc eucalyptus/publicips string |
|
40 |
eucalyptus-cc eucalyptus/dns string ${NAMESERVER}
|
|
41 |
eucalyptus-cc eucalyptus/cluster-name string cluster1 |
|
42 |
eucalyptus-nc eucalyptus/cluster-name string cluster1 |
|
43 |
eucalyptus-sc eucalyptus/cluster-name string cluster1 |
|
44 |
EOF |
|
45 |
||
46 |
# mount the second ephemeral storage to /var/lib/eucalyptus for |
|
47 |
# more space. |
|
48 |
mkdir /var/lib/eucalyptus |
|
49 |
printf "/dev/sdc\t/var/lib/eucalyptus\tauto\tdefaults\t0\t0\n" >> /etc/fstab |
|
50 |
mount /var/lib/eucalyptus |
|
51 |
||
52 |
apt-get update |
|
|
4
by Scott Moser
set DEBIAN_FRONTEND=noninteractive for apt-get commands [thanks andreas] |
53 |
DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes |
|
2
by Scott Moser
add user-data script for maverick |
54 |
|
55 |
# need to seed this: |
|
56 |
# eucalyptus-nc eucalyptus-nc/no_vmx error |
|
57 |
||
|
4
by Scott Moser
set DEBIAN_FRONTEND=noninteractive for apt-get commands [thanks andreas] |
58 |
DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes "eucalyptus-*" |
|
2
by Scott Moser
add user-data script for maverick |
59 |
|
60 |
stop eucalyptus CLEAN=1 |
|
61 |
stop eucalyptus-nc |
|
62 |
||
63 |
lfile=/etc/eucalyptus/eucalyptus.local.conf |
|
64 |
[ -e ${lfile}.dist ] || sudo cp ${lfile} ${lfile}.dist
|
|
65 |
||
66 |
cat <<EOF > "${lfile}"
|
|
67 |
VNET_INTERFACE="br0" |
|
68 |
VNET_PRIVINTERFACE="br0" |
|
69 |
VNET_MODE="MANAGED" |
|
70 |
VNET_SUBNET="172.19.0.0" |
|
71 |
VNET_NETMASK="255.255.0.0" |
|
72 |
VNET_DNS="${NAMESERVER}"
|
|
73 |
VNET_ADDRSPERNET="32" |
|
74 |
VNET_CLOUDIP="${IPADDR}"
|
|
75 |
VNET_LOCALIP="${IPADDR}"
|
|
76 |
VNET_PUBLICIPS="192.168.1.100-192.168.1.116" |
|
77 |
MAX_CORES="16" |
|
78 |
EOF |
|
79 |
||
80 |
ifile=/etc/network/interfaces |
|
81 |
if [ ! -e "${ifile}.dist" ]; then
|
|
82 |
sudo cp -a "${ifile}" "${ifile}.dist"
|
|
83 |
cat <<EOF | sudo tee "${ifile}"
|
|
84 |
auto lo |
|
85 |
iface lo inet loopback |
|
86 |
iface eth0 inet manual |
|
87 |
auto br0 |
|
88 |
iface br0 inet dhcp |
|
89 |
bridge_ports eth0 |
|
90 |
bridge_fd 9 |
|
91 |
bridge_hello 2 |
|
92 |
bridge_maxage 12 |
|
93 |
bridge_stp off |
|
94 |
EOF |
|
95 |
fi |
|
96 |
||
97 |
# TODO: probably better way to handle change to /etc/cloud/cloud-init.conf |
|
98 |
# to not have eth0 as we're brining up br0 now |
|
99 |
mv /etc/init/cloud-init.conf /etc/init/cloud-init.conf.disabled |
|
100 |
||
101 |
# from /usr/sbin/euca_conf |
|
102 |
sudo -Hu eucalyptus sh -xc 'echo ~eucalyptus; mkdir -p ~eucalyptus/.ssh && |
|
103 |
cat >> ~eucalyptus/.ssh/authorized_keys' < ~eucalyptus/.ssh/id_rsa.pub |
|
104 |
sudo -Hu eucalyptus sh -c "ssh-keyscan ${IPADDR} > ~eucalyptus/.ssh/known_hosts"
|
|
105 |
||
106 |
sed -i.dist "s/domain type='kvm'/domain type='qemu'/" \ |
|
107 |
/usr/share/eucalyptus/gen_kvm_libvirt_xml |
|
108 |
||
109 |
f=/etc/init/eucalyptus-nc.conf |
|
110 |
if [ ! -e $f.dist ]; then |
|
111 |
sed -i.dist "s/modprobe aoe/modprobe aoe || :/" "$f" |
|
112 |
fi |
|
113 |
||
114 |
# this actually gets eucalyptus started (due to upstart) |
|
115 |
stop networking ; start networking |
|
116 |
||
117 |
stop eucalyptus CLEAN=1 |
|
118 |
stop eucalyptus-nc |
|
119 |
start eucalyptus CLEAN=1; |
|
120 |
start eucalyptus-nc |
|
121 |
||
122 |
echo "sleeping for a bit" |
|
123 |
sleep 2m |
|
124 |
euca_conf --deregister-sc cluster1 |
|
125 |
euca_conf --deregister-cluster cluster1 |
|
126 |
euca_conf --register-cluster cluster1 ${IPADDR}
|
|
127 |
euca_conf --register-sc cluster1 ${IPADDR}
|
|
128 |
euca_conf --register-nodes "${IPADDR}"
|
|
129 |
||
130 |
# |
|
131 |
# |
|
132 |
# i think eucalyptus gets confused by the multiple addresses of the node |
|
133 |
# (it has 3 at least now). Deregister the non-real ones |
|
134 |
sudo euca_conf --deregister-nodes 192.168.122.1 |
|
135 |
||
136 |
sudo -Hu ubuntu sh -c "cd && wget http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-i686-11.2_2.6.35-16_3.tar.gz" |
|
137 |
||
138 |
sudo -Hu ubuntu sh -c 'cd && mkdir -p euca && |
|
139 |
cd euca && sudo euca_conf --get-credentials mycreds.zip && |
|
140 |
unzip mycreds.zip && ln -s euca/eucarc ~/.eucarc && |
|
141 |
umask 066 && euca-add-keypair mykey > mykey.pem' |
|
142 |
||
|
3
by Scott Moser
fix uec-publish-tarball invocation |
143 |
sudo -Hu ubuntu sh -c 'cd && |
144 |
uec-publish-tarball ttylinux-uec-* ttylinux-uec i386' |
|
|
2
by Scott Moser
add user-data script for maverick |
145 |
|
146 |
echo "$(date): FINISHED!" |
|
147 |
||
148 |
# this image has 'password' as default password for 'ubuntu' or 'root' |
|
149 |
# uec-publish-tarball ttylinux-uec-*.tar.gz ttylinux-uec i386 |
|
150 |
# euca-run-instances --addressing private --key mykey emi-FDD3181B |
|
151 |
# ssh -i euca/mykey.pem ubuntu@172.19.1.2 |
|
152 |
||
153 |
# TODO: |
|
154 |
# guests do not have proper outbound networking if not launched with |
|
155 |
# "euca-run-instances --addressing private" |
|
156 |
# (host -> guest works, though) |