1
0
mirror of https://github.com/rancher/os.git synced 2025-06-18 11:17:25 +00:00
os/scripts/create-installed

58 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash
set -e
cd $(dirname $0)/..
source ./scripts/run-common
INSTALLER=${BASE}/dist/artifacts/installer.tar
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
mount -t 9p -o trans=virtio,version=9p2000.L config-2 /mnt
touch log
openvt -s -- tail -f log &
cat /mnt/installer.tar | system-docker load
ros install -d /dev/vda -f --no-reboot >log 2>&1
touch /mnt/success
EOF
rm -f build/{success,hd.img}
qemu-img create -f qcow2 build/hd.img 8G
cp ${INSTALLER} build/installer.tar
qemu-system-${QEMUARCH} -serial stdio \
-enable-kvm \
-drive if=virtio,file=build/hd.img \
-kernel ${KERNEL} \
-initrd ${INITRD} \
-m 2048 \
-append "${DEFAULT_KERNEL_ARGS}" \
-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