#! /bin/sh # locate the config file if [ "$1" = "-config" ]; then conffile=$2 shift 2 else conffile=./.qemurc fi # hard-coded defaults here qemu= vde=off boot=harddisk megs=32 fda= fdb= hda= hdachs= hdb= cdrom= hdc= hdd= audio=off pci=on macaddr= cirrus=off localtime=off usernet=off nics=1 netscript=/etc/qemu-ifup graphic=on # if we have a valid config file, load it if [ -f $conffile ]; then . $conffile fi # sanity check if [ -z "$boot" ]; then echo 'Option boot must be set to floppy, harddisk, or cdrom, or' echo 'the decapriated options a, c, or d!' exit 1 fi if [ -z "$megs" ]; then #TODO: make sure this is a number echo 'Option megs must be set to a valid number!' exit 1 fi if [ -z "$nics" ]; then #TODO: make sure this is a number echo 'Option nics must be set to a valid number! (most likely this number will be 1)' exit 1 fi if [ -z "$netscript" ]; then echo 'Warning: option netscript is not set. Will use /etc/qemu-ifup if asked.' fi #if [ "$boot" = "floppy" -o "$boot" = "a" ]; then #if [ -z "$fda" ]; then #echo 'Option fda must be set to a valid floppy image!' #exit 1 #fi #elif [ "$boot" = "harddisk" -o "$boot" = "c" ]; then #if [ -z "$hda" ]; then #echo 'Option hda must be set to a valid hard disk image!' #exit 1 #fi #elif [ "$boot" = "cdrom" -o "$boot" = "d" ]; then #if [ -z "$cdrom" ]; then #echo 'Option cdrom must be set to a valid cdrom iso image!' #exit 1 #fi #else # sanity check #echo -n "Option boot set to unknown value $boot. " #echo 'I don't know what to do!' #exit 1 #fi # convert recommended values to the one qemu expects if [ "$boot" = "floppy" ]; then boot=a elif [ "$boot" = "harddisk" ]; then boot=c elif [ "$boot" = "cdrom" ]; then boot=d fi # isa hack (Note that setting $pci overrides $isa completely) if [ -z "$pci" ]; then if [ "$isa" = "on" ]; then pci = off else pci = on fi fi # interpret out configuration comline=`which qemu` if [ -n "$qemu" ]; then comline="$qemu" fi if [ "$vde" = "on" ]; then comline="vdeq $comline" fi comline="$comline -boot $boot" comline="$comline -m $megs" if [ -n "$fda" ]; then comline="$comline -fda $fda" fi if [ -n "$fdb" ]; then comline="$comline -fdb $fdb" fi if [ -n "$hda" ]; then comline="$comline -hda $hda" fi if [ -n "$hdachs" ]; then comline="$comline -hdachs $hdachs" fi if [ -n "$hdb" ]; then comline="$comline -hdb $hdb" fi if [ -n "$cdrom" ]; then comline="$comline -cdrom $cdrom" fi if [ -n "$hdc" ]; then comline="$comline -hda $hdc" fi if [ -n "$hdd" ]; then comline="$comline -hda $hdd" fi if [ "$audio" = "on" ]; then comline="$comline -enable-audio" fi if [ "$pci" != "on" ]; then comline="$comline -isa" fi if [ -n "$macaddr" ]; then comline="$comline -macaddr $macaddr" fi if [ "$cirrus" = "on" ]; then comline="$comline -cirrusvga" fi if [ "$localtime" = "on" ]; then comline="$comline -localtime" fi if [ "$usernet" = "on" ]; then comline="$comline -user-net" elif [ "$usernet" = "dummy" ]; then comline="$comline -dummy-net" fi # Don't pass the parameter if it is the qemu default if [ "$nics" != "1" ]; then comline="$comline -nics $nics" fi if [ -n "$netscript" ]; then # Don't pass the parameter if it is the qemu default if [ "$netscript" != "/etc/qemu-ifup" ]; then comline="$comline -n $netscript" fi fi if [ "$graphic" != "on" ]; then comline="$comline -nographic" fi echo $comline "$@" exec $comline "$@"