-
Notifications
You must be signed in to change notification settings - Fork 1
/
start_emulator
executable file
·36 lines (28 loc) · 974 Bytes
/
start_emulator
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
#!/bin/sh
if [ -z "$1" ]
then
echo "Usage $0 <id>"
exit 1
fi
if [ -z "$ANDROID_HOME" ]
then
echo "Set the ANDROID_HOME environment variable to the location of your Android SDK"
exit 1
fi
ID="$1"
EMULATOR="emu$ID"
HEX=$(python -c "print('{0:02x}'.format($ID))")
export LD_LIBRARY_PATH=$ANDROID_HOME/tools/lib
# If you want more interfaces per emulator, add them here with unique names,
# and attach them to the emulator by copying the two "-net" lines below.
sudo ip tuntap add "$EMULATOR" mode tap
sleep 2
# If you want to actually see the emulator, and not just interact with it over
# something like ADB, remove the "nographic" flag here.
sudo -E emulator -avd $EMULATOR -qemu -m 512 -enable-kvm \
-nographic \
-net nic,vlan=1,macaddr=52:52:00:12:34:$HEX \
-net user,vlan=1,hostname="$EMULATOR" \
-net nic,vlan=2,macaddr=52:54:00:12:35:$HEX \
-net tap,ifname=${EMULATOR},script=no,vlan=2
sudo ip tuntap del "$EMULATOR" mode tap