about summary refs log tree commit diff stats
path: root/tools/scripts/system-qemu.sh
diff options
context:
space:
mode:
authorSilvino Silva <silvino@bk.ru>2016-10-15 01:59:41 +0100
committerSilvino Silva <silvino@bk.ru>2016-10-15 01:59:41 +0100
commit4006c1d2a5c82f9136f82b035e4083b487b01b5b (patch)
tree6b2f3c01cddee4c8307ff2ce279168c8952f6d11 /tools/scripts/system-qemu.sh
parent371d163d903373eea57cd6761223a579c18ed536 (diff)
parenta2e804ad93ef562c299dfad49eb890c8d7d24010 (diff)
downloaddoc-4006c1d2a5c82f9136f82b035e4083b487b01b5b.tar.gz
release 0.2.5
Diffstat (limited to 'tools/scripts/system-qemu.sh')
-rw-r--r--tools/scripts/system-qemu.sh65
1 files changed, 54 insertions, 11 deletions
diff --git a/tools/scripts/system-qemu.sh b/tools/scripts/system-qemu.sh
index 8c68e70..489af5e 100644
--- a/tools/scripts/system-qemu.sh
+++ b/tools/scripts/system-qemu.sh
@@ -1,15 +1,58 @@
 #!/bin/sh
-ISO=~/crux-3.2.iso
-IMG=~/crux-img.qcow2
 
-TAP=$1
+# First we define the function
+ConfirmOrExit ()
+{
+    while true
+    do
+        echo -n "Please confirm (y or n) :"
+        read CONFIRM
+        case $CONFIRM in
+            y|Y|YES|yes|Yes) break ;;
+            n|N|no|NO|No)
+                echo "Aborting - you entered $CONFIRM"
+                exit
+                ;;
+            *) echo "Please enter only y or n"
+        esac
+    done
+    echo "You entered $CONFIRM. Continuing ..."
+}
 
-echo "TAP: $TAP"
+SCRIPT=$(readlink -f "$0")
+# Absolute path this script is in, thus /home/user/bin
+SCRIPTPATH=$(dirname "$SCRIPT")
 
-qemu-system-x86_64 \
-    -enable-kvm \
-    -m 1024 \
-    -boot d \
-    -cdrom ${ISO} \
-    -hda ${IMG} \
-    -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
+DIR=$(dirname "$SCRIPTPATH");
+DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";
+
+MEM=$1
+TAP=$2
+ISO_FILE="${DIR_LOCAL}/$3"
+IMG="${DIR_LOCAL}/$4"
+
+echo "MEM (512): $MEM"
+echo "TAP (tap1): $TAP"
+echo "ISO_FILE (crux-3.2.iso): $ISO_FILE"
+echo "IMG (crux-img.qcow2): $IMG"
+ConfirmOrExit
+
+if [ "$ISO_FILE" = "$DIR_LOCAL/" ]
+then
+    qemu-system-x86_64 \
+        -enable-kvm \
+        -m $MEM \
+        -boot c \
+        -hda ${IMG} \
+        -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
+else
+    qemu-system-x86_64 \
+        -enable-kvm \
+        -m $MEM \
+        -boot d \
+        -cdrom ${ISO_FILE} \
+        -hda ${IMG} \
+        -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
+fi
+
+exit 0;