-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_flashx.sh
More file actions
executable file
·91 lines (80 loc) · 2.88 KB
/
run_flashx.sh
File metadata and controls
executable file
·91 lines (80 loc) · 2.88 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# ------------------------------------------------------------------------------
# Script: run_flashx.sh
#
# Purpose:
# Builds and runs the Flash-X Docker container with proper volume mounting
# and user/group permission handling across platforms (Linux, macOS, WSL).
#
# What it does:
# - Verifies Docker is running
# - Determines the operating system and sets up the appropriate volume mount
# - Ensures the host directory ($HOME/flashx) exists with the correct permissions
# - Builds the Docker image with the user's UID and GID passed as build args
# - Runs the Docker container with a volume mounted to the container's desktop
#
# Requirements:
# - Docker installed and running
# - WSL and wslpath available if running under Windows
# ------------------------------------------------------------------------------
set -e # Exit immediately on error
# If running inside a GitHub Codespace, the environment is already set up
# via devcontainer.json — no Docker build/run needed.
if [ "${CODESPACES}" = "true" ]; then
echo "Running inside GitHub Codespaces — Docker container not needed."
echo "The Flash-X environment is already available."
OBJECT_DIR="${HOME}/flashx/Flash-X/object"
if [ -d "$OBJECT_DIR" ]; then
echo "Launching shell in ${OBJECT_DIR}"
echo "Run ./flashx to execute the Sedov test."
cd "$OBJECT_DIR"
exec /bin/bash
else
echo "Error: ${OBJECT_DIR} not found."
echo "The dev container may not have built correctly."
exit 1
fi
fi
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "Docker is not running. Please start Docker and try again."
exit 1
fi
# Detect OS and set volume mount path
OS=$(uname -s)
HOME_DIR="$HOME"
MOUNT_DIR="${HOME_DIR}/flashx"
CONTAINER_MOUNT="/home/flashuser/flashx/Flash-X/desktop"
case "$OS" in
Linux|Darwin)
VOLUME_MOUNT="${MOUNT_DIR}:${CONTAINER_MOUNT}"
;;
MINGW*|CYGWIN*|MSYS*)
if ! command -v wslpath > /dev/null; then
echo "wslpath not found. Please run this script inside WSL or install wslpath."
exit 1
fi
WINDOWS_PATH=$(wslpath -w "$MOUNT_DIR")
VOLUME_MOUNT="${WINDOWS_PATH}:${CONTAINER_MOUNT}"
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
# Create the mount directory if it doesn't exist, and set permissions
mkdir -p "$MOUNT_DIR"
chmod 755 "$MOUNT_DIR"
chown "$(whoami):$(id -gn)" "$MOUNT_DIR"
echo "Mount directory prepared:"
ls -ld "$MOUNT_DIR"
# Build the Docker image with user and group IDs
docker build -t flashx-app --progress=plain -f flashx_dockerfile \
--build-arg USER_ID="$(id -u)" \
--build-arg GROUP_ID="$(id -g)" .
# Run the Docker container with the volume mount
docker run --rm -it \
--name flashx-container \
--hostname flashx \
-v "$VOLUME_MOUNT" \
flashx-app