-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdevstack-install-on-iso
More file actions
executable file
·126 lines (121 loc) · 3.63 KB
/
Copy pathdevstack-install-on-iso
File metadata and controls
executable file
·126 lines (121 loc) · 3.63 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
#!/bin/bash
devstack-install-on-iso()
{ apt-get update
apt-get install -y qemu
#iso_url="$1"
#: ${iso_url:=http://releases.ubuntu.com/14.04.3/ubuntu-14.04.3-server-amd64.iso}
#iso_base=$(basename $iso_url)
#iso=$(find -L ~/Downloads/ -name "$iso_base")
#if [ ! -e "$iso" ]; then
# wget -nc $iso_url -P ~/Downloads || return
# iso=~/Downloads/$iso_base
#fi
iso="add the path to your ubuntu iso since one 14.04 is no longer available only as torrent"
sudo mkdir -p /mnt/tmp
sudo mount $iso /mnt/tmp -o user,ro
cat /mnt/tmp/.disk/*info
echo
read a b c < /mnt/tmp/.disk/*info
fs=$a-$b
if [ ! -e $fs ]; then
cp -a /mnt/tmp $fs
chmod -R +w $fs
fi
sudo umount /mnt/tmp
kickstart-cfg $fs
declare -f devstack-start > $fs/devstack-start
echo devstack-start >> $fs/devstack-start
chmod +x $fs/devstack-start
cat >> $fs/ks.cfg <<-EOF
%post --nochroot
mkdir -p /target/home/$USER/.ssh/ /target/usr/local/bin
cp /cdrom/devstack-start /target/home/$USER/
cp /cdrom/devstack-start /target/usr/local/bin
echo $(cat ~/.ssh/id_rsa.pub) >> /target/home/$USER/.ssh/authorized_keys
chown -R $USER /target/home/$USER/.ssh/
%end
EOF
image=$fs-devstack
mkisofs -q -disable-deep-relocation -rational-rock -cache-inodes -joliet \
-full-iso9660-filenames -no-emul-boot -boot-load-size 4 -boot-info-table \
-eltorito-boot isolinux/isolinux.bin -eltorito-catalog isolinux/boot.cat \
-o $image.iso $fs
qemu-img create -f qcow2 $image.qcow2 10G
qemu-system-x86_64 -smp 2 -enable-kvm -m 3G --cdrom $image.iso $image.qcow2
# References:
# http://askubuntu.com/questions/122505/how-do-i-create-a-completely-unattended-install-of-ubuntu
# https://help.ubuntu.com/lts/installation-guide/i386/ch04s06.html
# https://help.ubuntu.com/community/KickstartCompatibility
}
kickstart-cfg()
{
echo en > $1/isolinux/lang
cat > $1/isolinux/isolinux.cfg <<- EOF
default install
label install
menu label ^Install Ubuntu Server
kernel /install/vmlinuz
append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed --
EOF
cat > $1/ks.cfg <<-EOF
lang en_US
langsupport en_US
keyboard us
timezone $(cat /etc/timezone)
rootpw --disabled
user $USER --fullname $USER --password $USER
text
install
cdrom
bootloader --location=mbr
zerombr yes
clearpart --all --initlabel
auth --useshadow --enablemd5
firewall --disabled
skipx
reboot
EOF
cat > $1/ks.preseed <<-EOF
d-i user-setup/allow-password-weak boolean true
d-i partman/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm_nooverwrite boolean true
d-i pkgsel/include string git openssh-server rabbitmq-server qemu-kvm apache2 libapache2-mod-wsgi libvirt-bin libvirt-dev
EOF
}
devstack-start()
{
test -d devstack || git clone https://git.openstack.org/openstack-dev/devstack
devstack/tools/create-stack-user.sh;
cd devstack;
if [ ! -e local.conf ]; then
cat > local.conf <<-'EOF'
[[local|localrc]]
ADMIN_PASSWORD=password
DATABASE_PASSWORD=$ADMIN_PASSWORD
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
DEST=/opt/stack
LOGDIR=$DEST/logs
LOGFILE=$DEST/logs/stack.sh.log
LOG_COLOR=False
#LOGDAYS=100
#OFFLINE=True
EOF
fi
./stack.sh
. openrc admin
nova tenant-network-list
nova image-list
nova boot --flavor 1 --image cirros-0.3.4-x86_64-uec my_inst
nova list
nova stop my_inst
nova delete my_inst
}
if [ `which "$0"` = "$SHELL" ]; then
echo Function devstack-install-on-iso is loaded into the shell environment
else
devstack-install-on-iso "$@"
fi