#!/bin/bash function help() { cat <<-EOF usage: node.sh [--vnc] n Where n is the node number to start and is 1 ≤ n ≤ 5 EOF } n=0 while (( $# > 0 )) do case $1 in --vnc) vnc=true ;; [1-5]) n=$1 ;; -h|--help) help exit 0 ;; *) help exit 1 ;; esac shift done (( $n == 0 )) && help && exit 1 graphic="nographic" if [[ $vnc ]] then graphic="vnc :$n" fi source $(dirname $0)/nodes.sh uuid=${quuids[$n]} mac=${macs[$n]} set -x truncate -s0 hv$n qemu-img create -f qcow2 hv$n 10G qemu-system-x86_64 \ -option-rom /usr/share/qemu/pxe-virtio.rom \ -boot n \ -$graphic \ -cpu host -smp 2 \ -machine accel=kvm \ -global isa-fdc.driveA= \ -drive if=virtio,file=hv$n,cache=none,format=qcow2 \ -m 4096 \ -uuid $uuid \ -netdev type=tap,id=net0,script=$PWD/ifup,downscript=/bin/true -device e1000,netdev=net0,mac=$mac \