From 2cd67d9bbecff7b4509e70db0e8772bf7d82337c Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 25 Apr 2017 20:30:23 +0000 Subject: [PATCH] make qcow images customizable, and build one for Digital Ocean Signed-off-by: Sven Dowideit --- Makefile | 15 +++++------ scripts/images/openstack/Dockerfile.dapper | 1 + scripts/images/openstack/scripts/build.sh | 17 +++++++++--- scripts/run | 30 +++++++++++++++++++--- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index fc736eb1..5b08fbc8 100755 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ shell-bind: .dapper clean: @./scripts/clean -release: .dapper release-build openstack +release: .dapper release-build qcows release-build: mkdir -p dist @@ -44,17 +44,14 @@ itest: mkdir -p dist ./.dapper integration-test 2>&1 | tee dist/itest.log -openstack: +qcows: cp dist/artifacts/rancheros.iso scripts/images/openstack/ - cd scripts/images/openstack && ../../../.dapper + cd scripts/images/openstack && \ + NAME=openstack ../../../.dapper + cd scripts/images/openstack && \ + APPEND="console=tty1 rancher.debug=true printk.devkmsg=on notsc clocksource=kvm-clock rancher.network.interfaces.eth0.ipv4ll rancher.cloud_init.datasources=[digitalocean] rancher.autologin=tty1 rancher.autologin=ttyS0" NAME=digitalocean ../../../.dapper cp ./scripts/images/openstack/dist/*.img dist/ -openstack-run: - qemu-system-x86_64 -curses \ - -net nic -net user \ - -m 2048M \ - --hdc scripts/images/openstack/dist/rancheros-openstack.img - rpi: release # scripts/images/raspberry-pi-hypriot/dist/rancheros-raspberry-pi.zip cp dist/artifacts/rootfs_arm.tar.gz scripts/images/raspberry-pi-hypriot/ diff --git a/scripts/images/openstack/Dockerfile.dapper b/scripts/images/openstack/Dockerfile.dapper index 63a20562..b0603e66 100755 --- a/scripts/images/openstack/Dockerfile.dapper +++ b/scripts/images/openstack/Dockerfile.dapper @@ -12,3 +12,4 @@ CMD ["/source/scripts/build.sh"] ENV DAPPER_RUN_ARGS --device /dev/kvm ENV DAPPER_OUTPUT dist +ENV DAPPER_ENV APPEND NAME diff --git a/scripts/images/openstack/scripts/build.sh b/scripts/images/openstack/scripts/build.sh index db1634f9..393d1010 100755 --- a/scripts/images/openstack/scripts/build.sh +++ b/scripts/images/openstack/scripts/build.sh @@ -1,10 +1,15 @@ #!/bin/bash -set -e +set -ex cd $(dirname $0)/.. mkdir -p {dist,build/openstack/latest} +if [ "$APPEND" != "" ]; then + echo "--append ${APPEND}" + APPEND_PARAM="--append \"${APPEND}\"" +fi + cat > build/openstack/latest/user_data << EOF #!/bin/bash set -e @@ -16,7 +21,11 @@ mount -t 9p -o trans=virtio,version=9p2000.L config-2 /mnt touch log sleep 5 openvt -s -- tail -f log & -ros install -d /dev/vda -f --no-reboot >log 2>&1 +ros install \ + -d /dev/vda \ + ${APPEND_PARAM} \ + -f \ + --no-reboot >log 2>&1 touch /mnt/success EOF @@ -32,5 +41,5 @@ kvm -curses \ [ -f build/success ] -echo Converting dist/rancheros-openstack.img -qemu-img convert -c -O qcow2 build/hd.img dist/rancheros-openstack.img +echo Converting dist/rancheros-${NAME}.img +qemu-img convert -c -O qcow2 build/hd.img dist/rancheros-${NAME}.img diff --git a/scripts/run b/scripts/run index f0c18e7a..7ebf81cc 100755 --- a/scripts/run +++ b/scripts/run @@ -25,8 +25,29 @@ while [ "$#" -gt 0 ]; do --pxe) BOOT_PXE=1 ;; + --do) + BOOT_HD=1 + QEMU=0 + QIND=0 + REBUILD=0 + CONSOLEDISPLAY=1 + USE_OPENSTACK_IMG="digitalocean" + ;; + --digitalocean) + BOOT_HD=1 + QEMU=0 + QIND=0 + REBUILD=0 + CONSOLEDISPLAY=1 + USE_OPENSTACK_IMG="digitalocean" + ;; --openstack) - USE_OPENSTACK_IMG=1 + BOOT_HD=1 + QEMU=0 + QIND=0 + REBUILD=0 + CONSOLEDISPLAY=1 + USE_OPENSTACK_IMG="openstack" ;; --append) shift 1 @@ -155,12 +176,13 @@ if [ "$QEMU" == "1" ] || [ "$BOOT_ISO" == "1" ] || [ "$BOOT_HD" == "1" ]; then if [ ! -e ${HD} ]; then mkdir -p $(dirname ${HD}) - if [ "$USE_OPENSTACK_IMG" == "1" ]; then - if [ ! -e "dist/rancheros-openstack.img" ]; then + if [ "$USE_OPENSTACK_IMG" != "" ]; then + if [ ! -e "dist/rancheros-${USE_OPENSTACK_IMG}.img" ]; then echo "please build the open stack image first (run make release)." exit 1 fi - cp dist/rancheros-openstack.img $HD + cp dist/rancheros-${USE_OPENSTACK_IMG}.img $HD + qemu-img resize ${HD} +10GB else if [ ¨$INSTALLED¨ == ¨1¨ ]; then ./scripts/create-installed