forked from zyga/devtools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-devel-vm
executable file
·91 lines (81 loc) · 2 KB
/
run-devel-vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
version="0.2"
visual=no
# Handle command line arguments
while [ -n "$1" ]; do
case "$1" in
--visual)
visual=yes
shift
;;
--help|-h)
echo "Usage: run-devel-vm [device name]"
exit 0
;;
--version)
echo "run-devel-vm, version $version"
exit 0
;;
*)
# Perhaps it is a device name?
case $1 in
pc|i386)
device="$1"
shift
;;
pi2|bbb|dragon)
echo "Running this device as a VM is not supported." 1>&2
exit 1
;;
*)
echo "Unrecognized argument: $1" 1>&2
exit 1
;;
esac
;;
esac
done
# Interactively ask about the device if necessary.
while [ -z "$device" ]; do
echo "Which device do you have?"
echo
echo "Supported guest (virtualized) devices:"
echo " pc: Modern Intel/AMD Computer (64 bit)"
echo " i386: Legacy Intel/AMD Computer (32 bit)"
echo
echo -n "device> "
read device
case "$device" in
pc|i386)
;;
pi2|bbb|dragon)
device=""
echo "Running this device as a VM is not supported."
;;
*)
echo "Unrecognized device name: $device"
device=""
;;
esac
done
# Build an image if necessary
if [ ! -e $device-devel.img ]; then
sudo ./ubuntu-image --developer-mode $device || exit $?
fi
# Find out which qemu executable to use
case $device in
pc)
qemu="qemu-system-x86_64"
;;
i386)
qemu="qemu-system-i386"
;;
esac
qemu_options="-m 512 -snapshot -redir tcp:8022::22"
case $visual in
no)
qemu_options="$qemu_options -nographic"
;;
esac
# Run qemu
exec sudo "$qemu" $qemu_options "$device-devel.img"