morpheus

suckless linux distro
git clone git://git.2f30.org/morpheus
Log | Files | Refs | Submodules | README | LICENSE

commit 8b80aef576b5edd90b284dc86165059401e7c8ea
parent 60c05517628c456470c3138276f4c681aff58752
Author: lostd <lostd@2f30.org>
Date:   Thu, 13 Feb 2014 19:41:47 +0200

Creates overlay images and boot scripts

Diffstat:
Aqemu-mk-overlay | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+), 0 deletions(-)

diff --git a/qemu-mk-overlay b/qemu-mk-overlay @@ -0,0 +1,60 @@ +#!/bin/sh + +# creates an overlay qemu image using another image as base +# also prepares a script to boot the image +# depends: qemu +# +# configure the br0 interface as global bridge: +# https://wiki.archlinux.org/index.php/Bridge_with_netctl +# +# /etc/qemu-ifup: +# sudo ifconfig $1 0.0.0.0 promisc up +# sudo brctl addif br0 $1 +# sleep 2 +# +# /etc/qemu-ifdown: +# sudo brctl delif br0 $1 +# +# on the console set the vnc password: +# change vnc password xxx + +USAGE() { + echo "Usage: $(basename $0) base [n [mem]]" 1>&2 + exit 1 +} + +BASE=$(test -n "$1" && echo "$1") +N=$(test -n "$2" && echo "$2" || echo 1) +MEM=$(test -n "$3" && echo "$3" || echo 128M) + +test -f "$BASE" || + { echo "File $BASE does not exist" 1>&2 && USAGE; } +test "$N" -ge 0 && test "$N" -le 99 || + { echo "Provide a number in 0--99 for n" 1>&2 && USAGE; } + +NN=$(printf "%02d" $N) +IMAGE=vm${NN}.img +INITSH=vm${NN}.sh +MACADDR="52:54:ff:12:34:$NN" + +test -f "$IMAGE" && + { echo "File $IMAGE exists" 1>&2 && USAGE; } +test -f "$INITSH" && + { echo "File $INITSH exists" 1>&2 && USAGE; } + +MKBOOT() { +cat << EOF > $INITSH +#!/bin/sh + +qemu-system-x86_64 \\ + -enable-kvm \\ + -m $MEM \\ + -hda $IMAGE \\ + -net nic,macaddr=$MACADDR -net tap \\ + -vnc :$N,password -monitor stdio +EOF +} + +qemu-img create -f qcow2 -b $BASE $IMAGE +MKBOOT +chmod +x $INITSH