You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB
Bash

#!/bin/bash
hda="disco.qcow2"
mem="8G"
diskSize="40G"
nCores="4"
pwd="$(pwd)";path=${BASH_SOURCE[0]}
dir="$(echo "$pwd/$path"| rev | cut -d "/" -f2-100|rev)"
cd $dir
iso="$(ls -1 *.iso | head -1)"
opt="$1"
function who { if [ "$(whoami)" = "root" ]; then exit; fi }
function createQcow2 {
qemu-img create -f qcow2 "$hda" $diskSize
}
function checkQcow2 { if [ ! -f "$dir/$hda" ]; then createQcow2; fi }
function bootCD {
qemu-system-x86_64 -enable-kvm -m $mem -cpu host -smp cpus=$nCores -machine type=pc,accel=kvm -boot d -cdrom "$iso" -hda $hda
}
function bootHD {
qemu-system-x86_64 -enable-kvm -m $mem -cpu host -smp cpus=$nCores -machine type=pc,accel=kvm -net nic,model=e1000 -hda $hda -net user
}
function showHelp {
echo -e "start.sh - fanta <fanta@56k.es>\n"
echo "--help Show this help"
echo "--hd Boot from HD"
echo -e "--cdrom To install system booting from iso (cdrom)\n"
}
function checkOpt {
if [ -z "$opt" ]; then showHelp; fi
if [ "$opt" = "--help" ]; then showHelp; fi
if [ "$opt" = "--hd" ]; then bootHD; fi
if [ "$opt" = "--cdrom" ]; then bootCD; fi
}
function main() {
who
checkQcow2
checkOpt
}
main