-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-vm
executable file
·93 lines (83 loc) · 2.62 KB
/
run-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
92
93
#!/usr/bin/env bash
#
# Adapted version of the following
# https://github.com/rumpkernel/rumprun-packages/blob/master/erlang/erlrun.sh
#
script_dir="$(dirname "$(readlink -f "$0")")"
show_help() {
cat << EOF
Usage: "${0##*/}" [-h] ...
-h|--help display this help and exit
--erlhome Erlang Home. (Default: /tmp)
--erlpath Path to erlang installation. (Default: /opt/erlang)
--ip Which IP to configure this VM on. (Default 10.0.120.101)
--gw Which gateway to configure this VM on. (Default 10.0.120.100)
--virt virtualization. One of xen, qemu, kvm
--epmd Enable Epmd. Requires the following options:
--cookie Set a specific cookie. (Default: mycookie)
--name Set a different name. (Default: rumprun)
--iso Set an iso filename.
EOF
}
main() {
local erlhome=/tmp
local erlpath=/opt/erlang
local name=rumprun
local ip=10.0.120.101
local gw=10.0.120.100
local cookie=mycookie
local virt=qemu
local epmd_opt=-no_epmd
local epmd_conf=
local iso=
local OPTIND=1 # Reset is necessary if getopts was used previously
while getopts "h-:" opt; do
case "$opt" in
h) show_help
exit 0
;;
-)
case "$OPTARG" in
erlhome=*) erlhome="${OPTARG#*=}" ;;
erlpath=*) erlpath="${OPTARG#*=}" ;;
ip=*) ip="${OPTARG#*=}" ;;
gw=*) gw="${OPTARG#*=}" ;;
virt=*) virt="${OPTARG#*=}" ;;
epmd) epmd_opt='' ;;
cookie=*) cookie="${OPTARG#*=}" ;;
name=*) name="${OPTARG#*=}" ;;
iso=*) iso="${OPTARG#*=}" ;;
*) show_help
exit 1
;;
esac;;
*) show_help
exit 1
;;
esac
done
if [[ -z "$iso" ]];
then
echo "Missing mandatory option --iso"
exit 1
fi
[[ -z "$epmd_opt" ]] && {
epmd_conf="-s erlpmd_ctl start -s setnodename start $name@$ip $cookie"
}
# use "-mode embedded" for initial loading of all the modules (non-default)
rumprun "$virt" \
-I if,vioif,'-net tap,script=no,ifname=tap0' \
-W if,inet,static,"$ip/24","$gw" \
-e ERL_INETRC="$erlpath/erl_inetrc" \
-b ${iso},"$erlpath" \
-M 256 \
-g '-serial file:serial.log -nographic -vga none' \
-i build/rumprun-packages/erlang/beam.hw.bin \
"-K true \
-- $epmd_opt -root $erlpath/lib/erlang \
-progname erl -- \
-home $erlhome -noshell -noinput \
-mode embedded \
$epmd_conf"
}
main "$@"