| 
									
										
										
										
											2016-08-28 08:57:52 -07:00
										 |  |  | #!/bin/bash | 
					
						
							| 
									
										
										
										
											2017-01-16 12:37:01 +10:00
										 |  |  | set -ex | 
					
						
							| 
									
										
										
										
											2016-08-28 08:57:52 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | cd $(dirname $0)/.. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | source ./scripts/run-common | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ ! -e ${INITRD} ]; then | 
					
						
							|  |  |  |     cp bin/ros ${INITRD_SRC}/usr/bin/ros | 
					
						
							|  |  |  |     ./scripts/hash-initrd | 
					
						
							|  |  |  |     pushd ${INITRD_SRC} >/dev/null | 
					
						
							|  |  |  |     find . | cpio -H newc -o | gzip -1 > ${INITRD} | 
					
						
							|  |  |  |     popd >/dev/null | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | mkdir -p {dist,build/openstack/latest} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cat > build/openstack/latest/user_data << EOF | 
					
						
							|  |  |  | #!/bin/bash | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | trap "poweroff" EXIT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | sleep 5 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | touch log | 
					
						
							|  |  |  | openvt -s -- tail -f log & | 
					
						
							| 
									
										
										
										
											2017-01-16 12:37:01 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | mount -t 9p -o trans=virtio,version=9p2000.L config-2 /mnt | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # use the install tarball in the iso | 
					
						
							|  |  |  | ros install -d /dev/vda -f --no-reboot --append "console=ttyS0 rancher.autologin=ttyS0" >> /mnt/log 2>&1 | 
					
						
							| 
									
										
										
										
											2016-08-28 08:57:52 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | touch /mnt/success | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | rm -f build/{success,hd.img} | 
					
						
							|  |  |  | qemu-img create -f qcow2 build/hd.img 8G | 
					
						
							|  |  |  | qemu-system-${QEMUARCH} -serial stdio \ | 
					
						
							|  |  |  |     -enable-kvm \ | 
					
						
							|  |  |  |     -drive if=virtio,file=build/hd.img \ | 
					
						
							| 
									
										
										
										
											2017-01-16 12:37:01 +10:00
										 |  |  |     -boot d -cdrom ./dist/artifacts/rancheros.iso \ | 
					
						
							| 
									
										
										
										
											2016-08-28 08:57:52 -07:00
										 |  |  |     -m 2048 \ | 
					
						
							|  |  |  |     -smp 1 \ | 
					
						
							|  |  |  |     -nographic \ | 
					
						
							|  |  |  |     -display none \ | 
					
						
							|  |  |  |     -fsdev local,id=conf,security_model=none,path=$(pwd)/build \ | 
					
						
							|  |  |  |     -device virtio-9p-pci,fsdev=conf,mount_tag=config-2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ -f build/success ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | mkdir -p state | 
					
						
							|  |  |  | cp build/hd.img state/hd.img | 
					
						
							| 
									
										
										
										
											2017-01-16 12:37:01 +10:00
										 |  |  | echo "------------------------ RancherOS installed to hd.img." |