create-installed 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. set -ex
  3. cd $(dirname $0)/..
  4. source ./scripts/run-common
  5. if [ ! -e ${INITRD} ]; then
  6. cp bin/ros ${INITRD_SRC}/usr/bin/ros
  7. ./scripts/hash-initrd
  8. pushd ${INITRD_SRC} >/dev/null
  9. find . | cpio -H newc -o | gzip -1 > ${INITRD}
  10. popd >/dev/null
  11. fi
  12. mkdir -p {dist,build/openstack/latest}
  13. cat > build/openstack/latest/user_data << EOF
  14. #!/bin/bash
  15. set -e
  16. trap "poweroff" EXIT
  17. sleep 5
  18. touch log
  19. openvt -s -- tail -f log &
  20. mount -t 9p -o trans=virtio,version=9p2000.L config-2 /mnt
  21. # use the install tarball in the iso
  22. ros install -d /dev/vda -f --no-reboot --append "console=ttyS0 rancher.autologin=ttyS0" >> /mnt/log 2>&1
  23. touch /mnt/success
  24. EOF
  25. rm -f build/{success,hd.img}
  26. qemu-img create -f qcow2 build/hd.img 8G
  27. qemu-system-${QEMUARCH} -serial mon:stdio \
  28. -enable-kvm \
  29. -drive if=virtio,file=build/hd.img \
  30. -boot d -cdrom ./dist/artifacts/rancheros.iso \
  31. -m 2048 \
  32. -smp 1 \
  33. -nographic \
  34. -display none \
  35. -fsdev local,id=conf,security_model=none,path=$(pwd)/build \
  36. -device virtio-9p-pci,fsdev=conf,mount_tag=config-2
  37. [ -f build/success ]
  38. mkdir -p state
  39. cp build/hd.img state/hd.img
  40. echo "------------------------ RancherOS installed to hd.img."