-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfvp.sh
More file actions
executable file
·73 lines (59 loc) · 1.81 KB
/
Copy pathfvp.sh
File metadata and controls
executable file
·73 lines (59 loc) · 1.81 KB
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
#!/usr/bin/env bash
MODEL="$(basename "$0")"
DIRNAME="$(dirname "$(realpath "$0")")"
source "${DIRNAME}/fvprc"
FLAGS=()
PORTS=()
DISPLAY_IP="docker.for.mac.host.internal"
while [[ $# -gt 0 ]]; do
case $1 in
--display-ip)
DISPLAY_IP="$2"
shift 2
;;
*)
FLAGS+=("$1")
shift
;;
esac
done
if [[ "${FLAGS[*]}" =~ "-I" || "${FLAGS[*]}" =~ "--iris-server" ]]; then
PORTS+=("-p" "7100:7100")
if [[ ! "${FLAGS[*]}" =~ "--print-port-number" && ! "${FLAGS[*]}" =~ "-p" ]]; then
FLAGS+=("--print-port-number")
fi
if [[ ! "${FLAGS[*]}" =~ "--iris-allow-remote" && ! "${FLAGS[*]}" =~ "-A" ]]; then
FLAGS+=("--iris-allow-remote")
fi
fi
if ! docker image inspect "fvp:${FVP_VERSION}" >/dev/null 2>&1; then
"${DIRNAME}/build.sh"
fi
# Set mount_dir from environment variable or default to home
mount_dir="${FVP_MOUNT_DIR:-$HOME}"
# Validate mount_dir exists and is a directory
if [[ ! -d "$mount_dir" ]]; then
echo "Error: FVP_MOUNT_DIR '$mount_dir' is not a valid directory" >&2
exit 1
fi
# Set workdir from environment variable or default to pwd
workdir="${FVP_WORKDIR:-$(pwd)}"
# Validate workdir exists if it's a subdirectory of mount_dir
if [[ "$workdir" == "$mount_dir"* && ! -d "$workdir" ]]; then
echo "Error: FVP_WORKDIR '$workdir' is not a valid directory" >&2
exit 1
fi
# Mount licenses
MOUNTS=(
"--mount" "type=bind,src=${HOME}/.armlm/,dst=${HOME}/.armlm/"
"--mount" "type=bind,src=${mount_dir}/,dst=${mount_dir}/"
)
docker run --rm \
"${PORTS[@]}" \
"${MOUNTS[@]}" \
--workdir "$workdir" \
--env "ARMLM_CACHED_LICENSES_LOCATION=${HOME}/.armlm" \
--env "DISPLAY=${DISPLAY_IP}:0" \
--volume /tmp/.X11-unix:/tmp/.X11-unix \
"fvp:${FVP_VERSION}" "${MODEL}" "${FLAGS[@]}"
exit