-
Notifications
You must be signed in to change notification settings - Fork 3
/
clab
executable file
·56 lines (53 loc) · 1.39 KB
/
clab
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
#!/bin/sh
SHARED="/tmp/shared"
PLATFORM=$(uname)
if [ -n "$1" ]; then
if [ "$PLATFORM" = "Darwin" ]; then
SHARED=$(greadlink -f $1)
else
SHARED=$(readlink -f $1)
fi
echo Using custom shared directory: $SHARED
else
if ! lsmod | grep -q -e sch_netem -e ebtables; then
echo "neither sch_netem nor ebables kernel modules are not loaded"
echo "try running sudo modprobe sch_netem ebtables"
exit 1
fi
echo Using default shared directory: $SHARED
fi
if [ -n "$2" ]; then
INTERACTIVE="--entrypoint /bin/bash"
else
INTERACTIVE=""
fi
if [ "$PLATFORM" = "Darwin" ]; then
xhost + 127.0.0.1
docker run -it --rm \
--name coreemu-lab \
-p 2000:22 \
-p 51051:50051 \
-v $SHARED:/shared \
--cap-add=NET_ADMIN \
--cap-add=SYS_ADMIN \
-e SSHKEY="$(cat ~/.ssh/id_rsa.pub)" \
-e DISPLAY=host.docker.internal:0 \
--privileged \
$INTERACTIVE \
gh0st42/coreemu-lab
else
xhost +local:root
docker run -it --rm \
--name coreemu-lab \
-p 2000:22 \
-p 51051:50051 \
-v $SHARED:/shared \
--cap-add=NET_ADMIN \
--cap-add=SYS_ADMIN \
-e SSHKEY="$(cat ~/.ssh/id_rsa.pub)" \
-e DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
--privileged \
$INTERACTIVE \
gh0st42/coreemu-lab
fi