This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
create
executable file
·52 lines (41 loc) · 1.74 KB
/
create
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
#!/bin/bash
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# Load the configurations for this os definition
if [ -f environment.sh ]; then
. environment.sh
else
exit 1
fi
curl "http://web.cecs.pdx.edu/~sage/notify2.cgi?message=The%20vm%20${INSTANCE_NAME}%20is%20being%20pre-populated" &> /dev/null
cloud_image="${cloud_images}/${OS_VARIANT}.img.raw"
if ! [ -f "$cloud_image" ];then
echo "Cloud image $cloud_image doesn't exist" 1>&2
exit 1
fi
if [ "${DISK_1_PATH}" = "" ];then
echo "No second disk for cloud init data" 1>&2
exit 1
fi
short_instance_name=$(echo $INSTANCE_NAME | cut -d '.' -f 1)
cloud_init_file="/tmp/cloud_init_$INSTANCE_NAME"
cloud_meta_file="/tmp/cloud_meta_$INSTANCE_NAME"
echo "#cloud-config" > $cloud_init_file
./cloud_data.rb >> $cloud_init_file
./meta_data.rb > $cloud_meta_file
/usr/bin/cloud-localds $cloud_init_file.img $cloud_init_file $cloud_meta_file && \
dd if="$cloud_init_file.img" of="$DISK_1_PATH" && \
dd if="$cloud_image" of="$DISK_0_PATH"
curl "http://web.cecs.pdx.edu/~sage/notify2.cgi?message=The%20vm%20${INSTANCE_NAME}%20is%20booting" &> /dev/null