Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Clean Lumier readme

f-trycuad80b68a3a7bf
diff --git a/libs/lumier/README.md b/libs/lumier/README.md
index edb25f7fa8..9e1c08e09c 100644
--- a/libs/lumier/README.md
+++ b/libs/lumier/README.md
@@ -15,140 +15,134 @@
</h1>
</div>
-**Lumier** provides a Docker-based interface for the `lume` CLI, allowing you to easily run macOS virtual machines inside a container with VNC access. It interacts directly with the `lume serve` API running on your host machine to manage VMs.
+macOS and Linux virtual machines in a Docker container.
+
+## What is Lumier?
+**Lumier** is an interface for running macOS virtual machines with minimal setup. It uses Docker as a packaging system to deliver a pre-configured environment that connects to the `lume` virtualization service running on your host machine. With Lumier, you get:
+
+- A ready-to-use macOS or Linux virtual machine in minutes
+- Browser-based VNC access to your VM
+- Easy file sharing between your host and VM
+- Simple configuration through environment variables
## Requirements
Before using Lumier, make sure you have:
-1. Install [lume](https://github.com/trycua/cua/blob/main/libs/lume/README.md) on your host machine and ensure `lume serve` is running (typically on port 3000).
-2. Docker installed on your host machine
+1. **Docker for Apple Silicon** - If you're not familiar with Docker, it's a platform that packages applications with their dependencies. Download it [here](https://desktop.docker.com/mac/main/arm64/Docker.dmg) and follow the installation instructions.
+
+2. **Lume** - This is the virtualization engine that powers Lumier. Install it with this command:
+```bash
+/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"
+```
+
+After installation, Lume runs as a background service and listens on port 3000. This service allows Lumier to create and manage virtual machines. If port 3000 is already in use on your system, you can specify a different port with the `--port` option when running the `install.sh` script.
-## Usage (Direct Docker Commands - Recommended)
+## How It Works
-The primary way to use Lumier is directly through Docker commands. This gives you full control over the container environment.
+> **Note:** We're using Docker primarily as a convenient delivery mechanism, not as an isolation layer. Unlike traditional Docker containers, Lumier leverages the Apple Virtualization Framework (Vz) through the `lume` CLI to create true virtual machines.
-Ensure `lume serve` is running on your host machine before starting the container.
+Here's what's happening behind the scenes:
+
+1. The Docker container provides a consistent environment to run the Lumier interface
+2. Lumier connects to the Lume service running on your host Mac
+3. Lume uses Apple's Virtualization Framework to create a true macOS virtual machine
+4. The VM runs with hardware acceleration using your Mac's native virtualization capabilities
+
+## Getting Started
```bash
-# 1. Build the Docker image (if not already built or pulled)
+# 1. Navigate to the Lumier directory
+cd libs/lumier
+
+# 2. Build the Docker image (first-time setup)
docker build -t lumier:latest .
-# 2. Run the container
+# 3. Run the container with temporary storage
docker run -it --rm \
--name lumier-vm \
-p 8006:8006 \
- -v $(pwd)/storage:/storage \
- -v $(pwd)/shared:/shared \
-e VM_NAME=lumier-vm \
-e VERSION=ghcr.io/trycua/macos-sequoia-cua:latest \
-e CPU_CORES=4 \
-e RAM_SIZE=8192 \
- -e HOST_STORAGE_PATH=$(pwd)/storage \
- -e HOST_SHARED_PATH=$(pwd)/shared \
lumier:latest
```
-Note that when using Docker directly, you're responsible for:
-- Ensuring `lume serve` is running on the host.
-- Building the Docker image (or pulling `trycua/lumier:latest`).
-- Providing all necessary environment variables (`-e`) and volume mounts (`-v`).
-- Mapping the VNC port (`-p 8006:8006`).
-
-See "Available Environment Variables" below for customization options.
+After running the command above, you can access your macOS VM through a web browser (e.g., http://localhost:8006).
-## Optional Helper Script (`lumier`)
+> **Note:** With the basic setup above, your VM will be reset when you stop the container (ephemeral mode). This means any changes you make inside the macOS VM will be lost. See the section below for how to save your VM state.
-For convenience, an optional helper script `lumier` is provided. It simplifies some common tasks like building the image and passing arguments to `docker run`.
+## Saving Your VM State
-### Installation (Optional, for `lumier` script)
-
-If you want to use the `lumier` helper script system-wide, you can install it:
+To save your VM state between sessions (so your changes persist when you stop and restart the container), you'll need to set up a storage location:
```bash
-# Option 1: Install to your user's bin directory (recommended)
-./install.sh
-
-# Option 2: Install to a custom directory
-./install.sh --install-dir=/usr/local/bin # May require sudo
+# First, create a storage directory if it doesn't exist
+mkdir -p storage
-# Option 3: View installation options
-./install.sh --help
+# Then run the container with persistent storage
+docker run -it --rm \
+ --name lumier-vm \
+ -p 8006:8006 \
+ -v $(pwd)/storage:/storage \
+ -e VM_NAME=lumier-vm \
+ -e VERSION=ghcr.io/trycua/macos-sequoia-cua:latest \
+ -e CPU_CORES=4 \
+ -e RAM_SIZE=8192 \
+ -e HOST_STORAGE_PATH=$(pwd)/storage \
+ lumier:latest
```
-### Using the Lumier Script
+This command creates a connection between a folder on your Mac (`$(pwd)/storage`) and a folder inside the Docker container (`/storage`). The `-v` flag (volume mount) and the `HOST_STORAGE_PATH` variable work together to ensure your VM data is saved on your host Mac.
-If you installed the script, you can use it as a wrapper around Docker commands:
+## Sharing Files with Your VM
-```bash
-# Show help for the script
-lumier help
-
-# Build the Docker image (optional, happens automatically on first run if not pulled)
-lumier build
+To share files between your Mac and the virtual machine, you can set up a shared folder:
-# Run a VM with default settings
-lumier run -it --rm
+```bash
+# Create both storage and shared folders
+mkdir -p storage shared
-# Run a VM with custom settings using Docker's -e flag
-lumier run -it --rm \
- --name lumier1-vm \
+# Run with both persistent storage and a shared folder
+docker run -it --rm \
+ --name lumier-vm \
-p 8006:8006 \
- -v $(pwd)/storage1:/storage \
- -v $(pwd)/shared1:/shared \
+ -v $(pwd)/storage:/storage \
+ -v $(pwd)/shared:/shared \
+ -e VM_NAME=lumier-vm \
-e VERSION=ghcr.io/trycua/macos-sequoia-cua:latest \
- -e CPU_CORES=8 \
- -e RAM_SIZE=16GB
-
-# Note:
-# The lumier script will automatically:
-# 1. Detect user-provided volume paths for /storage and /shared and use those exact paths
-# 2. If not specified, default to ./storage and ./shared in the current directory
-# 3. Pass the resolved paths to the container as HOST_STORAGE_PATH and HOST_SHARED_PATH
-# 4. Create any non-existent directories automatically via Docker's volume mounting
-# 5. Set the VM name from the container name
-#
-# You do NOT need to specify HOST_STORAGE_PATH or HOST_SHARED_PATH environment variables manually.
+ -e CPU_CORES=4 \
+ -e RAM_SIZE=8192 \
+ -e HOST_STORAGE_PATH=$(pwd)/storage \
+ -e HOST_SHARED_PATH=$(pwd)/shared \
+ lumier:latest
```
-## Available Environment Variables
+With this setup, any files you place in the `shared` folder on your Mac will be accessible from within the macOS VM, and vice versa.
-These variables can be set using Docker's `-e` flag:
+## Configuration Options
-- `VM_NAME`: Set the VM name (default: lumier)
-- `VERSION`: Set the VM image (default: ghcr.io/trycua/macos-sequoia-vanilla:latest)
-- `CPU_CORES`: Set the number of CPU cores (default: 4)
-- `RAM_SIZE`: Set the memory size in MB (default: 8192)
-- `DISPLAY`: Set the display resolution (default: 1024x768)
-- `HOST_SHARED_PATH`: Path on the host to share with the VM
-- `LUMIER_DEBUG`: Enable debug mode (set to 1)
+When running Lumier, you'll need to configure a few things:
-## Project Structure
+- **Port forwarding** (`-p 8006:8006`): Makes the VM's VNC interface accessible in your browser. If port 8006 is already in use, you can use a different port like `-p 8007:8006`.
-The project is organized as follows:
+- **Environment variables** (`-e`): Configure your VM settings:
+ - `VM_NAME`: A name for your virtual machine
+ - `VERSION`: The macOS image to use
+ - `CPU_CORES`: Number of CPU cores to allocate
+ - `RAM_SIZE`: Memory in MB to allocate
+ - `HOST_STORAGE_PATH`: Path to save VM state (when using persistent storage)
+ - `HOST_SHARED_PATH`: Path to the shared folder (optional)
-```
-lumier/
-├── Dockerfile # Main Docker image definition
-├── README.md # This file
-├── lumier # Main CLI script
-├── install.sh # Installation script
-├── src/ # Source code
-│ ├── bin/ # Executable scripts
-│ │ ├── entry.sh # Docker entrypoint
-│ │ └── utils.sh # Utility functions
-│ ├── config/ # Configuration
-│ │ └── constants.sh # Shared constants
-│ ├── hooks/ # Lifecycle hooks
-│ │ └── on-logon.sh # Run after VM boots
-│ └── lib/ # Shared library code
-│ └── vm.sh # VM management functions
-└── mount/ # Default shared directory
-```
+- **Background service**: The `lume serve` service should be running on your host (starts automatically when you install Lume using the `install.sh` script above).
-## VNC Access
+## Credits
-When a VM is running, you can access it via VNC through:
-http://localhost:8006/vnc.html
+This project was inspired by [dockur/windows](https://github.com/dockur/windows) and [dockur/macos](https://github.com/dockur/macos), which pioneered the approach of running Windows and macOS VMs in Docker containers.
-The password is displayed in the console output when the VM starts.
\ No newline at end of file
+Main differences with dockur/macos:
+- Lumier is specifically designed for macOS virtualization
+- Lumier supports Apple Silicon (M1/M2/M3/M4) while dockur/macos only supports Intel
+- Lumier uses the Apple Virtualization Framework (Vz) through the `lume` CLI to create true virtual machines, while dockur relies on KVM.
+- Image specification is different, with Lumier and Lume relying on Apple Vz spec (disk.img and nvram.bin)
\ No newline at end of file
diff --git a/libs/lumier/install.sh b/libs/lumier/install.sh
deleted file mode 100755
index 359ebdd45c..0000000000
--- a/libs/lumier/install.sh
+++ /dev/null
@@ -1,166 +0,0 @@
-#!/bin/bash
-set -e
-
-# Lumier Installer
-# This script installs Lumier to your system
-
-# Define colors for output
-BOLD=$(tput bold)
-NORMAL=$(tput sgr0)
-RED=$(tput setaf 1)
-GREEN=$(tput setaf 2)
-BLUE=$(tput setaf 4)
-YELLOW=$(tput setaf 3)
-
-# Default installation directory (user-specific, doesn't require sudo)
-DEFAULT_INSTALL_DIR="$HOME/.local/bin"
-INSTALL_DIR="${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}"
-
-# Script directory
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-
-# Parse command line arguments
-while [ "$#" -gt 0 ]; do
- case "$1" in
- --install-dir=*)
- INSTALL_DIR="${1#*=}"
- ;;
- --help)
- echo "${BOLD}${BLUE}Lumier Installer${NORMAL}"
- echo "Usage: $0 [OPTIONS]"
- echo ""
- echo "Options:"
- echo " --install-dir=DIR Install to the specified directory (default: $DEFAULT_INSTALL_DIR)"
- echo " --help Display this help message"
- echo ""
- echo "Examples:"
- echo " $0 # Install to $DEFAULT_INSTALL_DIR"
- echo " $0 --install-dir=/usr/local/bin # Install to system directory (may require root privileges)"
- echo " INSTALL_DIR=/opt/lumier $0 # Install to /opt/lumier (legacy env var support)"
- exit 0
- ;;
- *)
- echo "${RED}Unknown option: $1${NORMAL}"
- echo "Use --help for usage information"
- exit 1
- ;;
- esac
- shift
-done
-
-echo "${BOLD}${BLUE}Lumier Installer${NORMAL}"
-echo "This script will install Lumier to your system."
-
-# Check if we're running with appropriate permissions
-check_permissions() {
- # System directories that typically require root privileges
- SYSTEM_DIRS=("/usr/local/bin" "/usr/bin" "/bin" "/opt")
-
- NEEDS_ROOT=false
- for DIR in "${SYSTEM_DIRS[@]}"; do
- if [[ "$INSTALL_DIR" == "$DIR"* ]] && [ ! -w "$INSTALL_DIR" ]; then
- NEEDS_ROOT=true
- break
- fi
- done
-
- if [ "$NEEDS_ROOT" = true ]; then
- echo "${YELLOW}Warning: Installing to $INSTALL_DIR may require root privileges.${NORMAL}"
- echo "Consider these alternatives:"
- echo " • Install to a user-writable location: $0 --install-dir=$HOME/.local/bin"
- echo " • Create the directory with correct permissions first:"
- echo " sudo mkdir -p $INSTALL_DIR && sudo chown $(whoami) $INSTALL_DIR"
- echo ""
-
- # Check if we already have write permission (might have been set up previously)
- if [ ! -w "$INSTALL_DIR" ] && [ ! -w "$(dirname "$INSTALL_DIR")" ]; then
- echo "${RED}Error: You don't have write permission to $INSTALL_DIR${NORMAL}"
- echo "Please choose a different installation directory or ensure you have the proper permissions."
- exit 1
- fi
- fi
-}
-
-# Detect OS and architecture
-detect_platform() {
- OS=$(uname -s | tr '[:upper:]' '[:lower:]')
- ARCH=$(uname -m)
-
- if [ "$OS" != "darwin" ]; then
- echo "${RED}Error: Currently only macOS is supported.${NORMAL}"
- exit 1
- fi
-
- if [ "$ARCH" != "arm64" ]; then
- echo "${RED}Error: Lumier only supports macOS on Apple Silicon (ARM64).${NORMAL}"
- exit 1
- fi
-
- PLATFORM="darwin-arm64"
- echo "Detected platform: ${BOLD}$PLATFORM${NORMAL}"
-}
-
-# Check dependencies
-check_dependencies() {
- echo "Checking dependencies..."
-
- # Check if lume is installed
- if ! command -v lume &> /dev/null; then
- echo "${RED}Error: Lume is required but not installed.${NORMAL}"
- echo "Please install Lume first: https://github.com/trycua/cua/blob/main/libs/lume/README.md"
- exit 1
- fi
-
- # Check if netcat (nc) is installed - should be pre-installed on macOS
- if ! command -v nc &> /dev/null; then
- echo "${RED}Error: netcat (nc) is required but not found.${NORMAL}"
- echo "This should be pre-installed on macOS. Please check your system installation."
- exit 1
- fi
-
- # Check if Docker is installed
- if ! command -v docker &> /dev/null; then
- echo "${YELLOW}Warning: Docker is required but not installed.${NORMAL}"
- echo "Please install Docker: https://docs.docker.com/get-docker/"
- echo "Continuing with installation, but Lumier will not work without Docker."
- fi
-
- echo "${GREEN}All dependencies are satisfied.${NORMAL}"
-}
-
-# Copy the lumier script directly
-copy_lumier() {
- echo "Copying lumier script to $INSTALL_DIR..."
- cp "$SCRIPT_DIR/lumier" "$INSTALL_DIR/lumier"
- chmod +x "$INSTALL_DIR/lumier"
-}
-
-# Main installation flow
-main() {
- check_permissions
- detect_platform
- check_dependencies
-
- echo "Installing Lumier to $INSTALL_DIR..."
-
- # Create install directory if it doesn't exist
- mkdir -p "$INSTALL_DIR"
-
- # Copy the lumier script
- copy_lumier
-
- echo "${GREEN}Installation complete!${NORMAL}"
- echo "Lumier has been installed to ${BOLD}$INSTALL_DIR/lumier${NORMAL}"
-
- # Check if the installation directory is in PATH
- if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
- echo "${YELLOW}Warning: $INSTALL_DIR is not in your PATH.${NORMAL}"
- echo "To add it, run one of these commands based on your shell:"
- echo " For bash: echo 'export PATH=\"\$PATH:$INSTALL_DIR\"' >> ~/.bash_profile"
- echo " For zsh: echo 'export PATH=\"\$PATH:$INSTALL_DIR\"' >> ~/.zshrc"
- echo " For fish: echo 'fish_add_path $INSTALL_DIR' >> ~/.config/fish/config.fish"
- fi
-}
-
-# Run the installation
-main
\ No newline at end of file
diff --git a/libs/lumier/lumier b/libs/lumier/lumier
deleted file mode 100755
index a5c783e03f..0000000000
--- a/libs/lumier/lumier
+++ /dev/null
@@ -1,281 +0,0 @@
-#!/usr/bin/env bash
-
-# Exit on errors, undefined variables, and propagate errors in pipes
-set -eo pipefail
-
-# Always use the current working directory as the build context
-SCRIPT_DIR="$(pwd)"
-DEBUG=${LUMIER_DEBUG:-0}
-
-usage() {
- cat <<EOF
-Lumier - Docker container wrapper for lume Virtual Machines
-
-Usage: $(basename "$0") COMMAND [OPTIONS]
-
-Commands:
- run [DOCKER_ARGS] Build (if needed) and run the Lumier container with Docker args
- build [DOCKER_ARGS] Build the Lumier Docker image with optional Docker args
- push [TAG] Push the Lumier image to Docker Hub with optional tag
- pull Pull the trycua/lumier:latest image from Docker Hub
- help Show this help message
-
-Docker Container Environment Variables:
- These can be set using Docker's -e flag:
-
- VM_NAME Set the VM name (default: lumier)
- VERSION Set the VM image (default: ghcr.io/trycua/macos-sequoia-vanilla:latest)
- CPU_CORES Set the number of CPU cores (default: 4)
- RAM_SIZE Set the memory size in MB (default: 8192)
- HOST_STORAGE_PATH Path to mount as shared directory in the VM
- HOST_SHARED_PATH Path to mount as shared directory in the VM
- LUMIER_DEBUG Enable debug mode (set to 1)
-
-Script Environment Variables:
- LUMIER_IMAGE Docker image name (default: lumier:latest)
-
-Examples:
- # Run a VM with default settings
- $(basename "$0") run -it --rm
-
- # Run a VM with custom settings using Docker's -e flag
- $(basename "$0") run -it --rm \\
- --name custom-container-name \\
- -e VM_NAME=my-vm \\
- -e VERSION=ghcr.io/trycua/macos-sequoia-cua:latest \\
- -e RAM_SIZE=16384 \\
- -v $(pwd)/mount:/shared
-
- # Build with a custom image name
- LUMIER_IMAGE=myorg/lumier:v1 $(basename "$0") build
-
- # Push to Docker Hub
- $(basename "$0") push v1.0.0
-
- # Push with a custom image name
- LUMIER_IMAGE=myorg/lumier:v1 $(basename "$0") push
-
- # Pull trycua/lumier:latest from Docker Hub
- $(basename "$0") pull
-EOF
-}
-
-# Build the Docker image with cache busting
-build_image() {
- local image_name="${LUMIER_IMAGE:-lumier:latest}"
- echo "Building Lumier Docker image: $image_name"
- echo "SCRIPT_DIR=$SCRIPT_DIR"
- echo "Checking for Dockerfile at: $SCRIPT_DIR/Dockerfile"
- ls -l "$SCRIPT_DIR/Dockerfile" || echo "Dockerfile not found at $SCRIPT_DIR/Dockerfile"
-
- # Pass any additional arguments to docker build with cache busting
- docker build --build-arg CACHEBUST=$(date +%s) -t "$image_name" "$SCRIPT_DIR" "$@"
-
- echo "Lumier image built successfully: $image_name"
-}
-
-# Push the Docker image to Docker Hub
-push_image() {
- local image_name="${LUMIER_IMAGE:-lumier:latest}"
- local tag="${1:-latest}"
-
- # Ensure the Docker image exists
- if ! docker image inspect "$image_name" &>/dev/null; then
- echo "Docker image '$image_name' not found. Building it..."
- build_image
- fi
-
- # If the image doesn't have a Docker Hub repository format, use the tag argument
- if [[ "$image_name" != *"/"* && "$image_name" != "ghcr.io/"* ]]; then
- # If tag was provided and the image name doesn't already have a tag
- if [[ -n "$tag" && "$image_name" != *":"* ]]; then
- # Extract the base name without any tag
- local base_name="${image_name%%:*}"
- # Tag the image for Docker Hub with the provided tag
- local hub_image="${DOCKER_USERNAME:-trycua}/$base_name:$tag"
- echo "Tagging image $image_name as $hub_image"
- docker tag "$image_name" "$hub_image"
- image_name="$hub_image"
- else
- # Tag with Docker Hub username but keep the existing tag
- local base_name_with_tag="$image_name"
- local hub_image="${DOCKER_USERNAME:-trycua}/$base_name_with_tag"
- echo "Tagging image $image_name as $hub_image"
- docker tag "$image_name" "$hub_image"
- image_name="$hub_image"
- fi
- elif [[ "$image_name" != *":"* && -n "$tag" ]]; then
- # If the image has a repo format but no tag, add the provided tag
- image_name="${image_name}:${tag}"
- echo "Using image name with tag: $image_name"
- fi
-
- echo "Pushing image to Docker Hub: $image_name"
- docker push "$image_name"
- echo "Image pushed successfully: $image_name"
-}
-
-# Pull the trycua/lumier:latest image from Docker Hub
-pull_image() {
- local image_name="trycua/lumier:latest"
-
- echo "Pulling image from Docker Hub: $image_name"
- docker pull "$image_name"
-
- # Check if the pull was successful
- if docker image inspect "$image_name" &>/dev/null; then
- echo "Image pulled successfully: $image_name"
-
- # If LUMIER_IMAGE is set to something else, tag the pulled image with that name
- if [[ -n "${LUMIER_IMAGE}" && "${LUMIER_IMAGE}" != "$image_name" ]]; then
- echo "Tagging pulled image as ${LUMIER_IMAGE}"
- docker tag "$image_name" "${LUMIER_IMAGE}"
- echo "Image tagged successfully as ${LUMIER_IMAGE}"
- fi
- else
- echo "Failed to pull image: $image_name"
- exit 1
- fi
-}
-
-# Run the Docker container
-run_container() {
- local image_name="${LUMIER_IMAGE:-lumier:latest}"
-
- # Ensure the Docker image exists locally
- if ! docker image inspect "$image_name" &>/dev/null; then
- echo "Lumier image '$image_name' not found locally."
- # Check if it exists on Docker Hub (only for the default image)
- if [[ "$image_name" == "lumier:latest" ]]; then
- echo "Attempting to pull trycua/lumier:latest from Docker Hub..."
- if docker pull trycua/lumier:latest; then
- echo "Successfully pulled trycua/lumier:latest."
- image_name="trycua/lumier:latest" # Use the pulled image
- else
- echo "Failed to pull image from Docker Hub. Building locally..."
- build_image
- fi
- else
- echo "Building image locally..."
- build_image # Build other images if not found
- fi
- fi
-
- # Extract volume paths from arguments if provided
- STORAGE_PATH="${HOST_STORAGE_PATH:-./storage}"
- SHARED_PATH="${HOST_SHARED_PATH:-./shared}"
-
- # Parse user-provided volume arguments to extract paths
- local prev_was_v=false
- for arg in "$@"; do
- if $prev_was_v; then
- # Format is HOST_PATH:CONTAINER_PATH
- local host_path=${arg%%:*}
- local container_path=${arg#*:}
-
- # Update the paths based on container mount points
- if [[ "$container_path" == "/storage" ]]; then
- # Use the exact path provided by the user without calling realpath
- STORAGE_PATH="$host_path"
- elif [[ "$container_path" == "/shared" ]]; then
- # Use the exact path provided by the user without calling realpath
- SHARED_PATH="$host_path"
- fi
- prev_was_v=false
- elif [[ "$arg" == "-v" ]]; then
- prev_was_v=true
- elif [[ "$arg" == --volume=* ]]; then
- # Handle --volume=HOST:CONTAINER format
- local volume_spec=${arg#--volume=}
- local host_path=${volume_spec%%:*}
- local container_path=${volume_spec#*:}
-
- if [[ "$container_path" == "/storage" ]]; then
- # Use the exact path provided by the user without calling realpath
- STORAGE_PATH="$host_path"
- elif [[ "$container_path" == "/shared" ]]; then
- # Use the exact path provided by the user without calling realpath
- SHARED_PATH="$host_path"
- fi
- fi
- done
-
- # Note: Docker will automatically create these directories if they don't exist
-
- # Only add -e if not already present in args
- DOCKER_ARGS=( )
- add_env_var() {
- local var="$1"; local val="$2"; local flag="-e $var="
- for arg in "$@"; do
- [[ "$arg" == *"$flag"* ]] && return 0
- done
- DOCKER_ARGS+=( -e "$var=$val" )
- }
- add_env_var HOST_STORAGE_PATH "$STORAGE_PATH"
- add_env_var HOST_SHARED_PATH "$SHARED_PATH"
-
- # Detect --name argument and set VM_NAME if not already present
- local container_name=""
- local prev_arg=""
- for arg in "$@"; do
- if [[ "$prev_arg" == "--name" ]]; then
- container_name="$arg"
- break
- elif [[ "$arg" == --name=* ]]; then
- container_name="${arg#--name=}"
- break
- fi
- prev_arg="$arg"
- done
- # Only add -e VM_NAME if not already present and container_name is set
- local vm_name_set=false
- for arg in "$@"; do
- if [[ "$arg" == "-e" ]] && [[ "$2" == VM_NAME=* ]]; then
- vm_name_set=true
- break
- elif [[ "$arg" == "-eVM_NAME="* ]]; then
- vm_name_set=true
- break
- elif [[ "$arg" == "-e"* ]] && [[ "$arg" == *"VM_NAME="* ]]; then
- vm_name_set=true
- break
- fi
- done
- if [[ -n "$container_name" && "$vm_name_set" != true ]]; then
- DOCKER_ARGS+=( -e "VM_NAME=$container_name" )
- fi
-
- echo "Running Lumier container with image: $image_name"
- if [[ "$*" == *"-p 8006:8006"* || "$*" == *"-p"*"8006:8006"* ]]; then
- docker run "${DOCKER_ARGS[@]}" "$@" "$image_name"
- else
- docker run "${DOCKER_ARGS[@]}" -p 8006:8006 "$@" "$image_name"
- fi
-}
-
-# Main command handling
-case "${1:-help}" in
- run)
- shift
- run_container "$@"
- ;;
- build)
- shift
- build_image "$@"
- ;;
- push)
- shift
- push_image "$@"
- ;;
- pull)
- pull_image
- ;;
- help)
- usage
- ;;
- *)
- echo "Unknown command: $1"
- usage
- exit 1
- ;;
-esac
\ No newline at end of file
diff --git a/libs/lumier/src/bin/entry.sh b/libs/lumier/src/bin/entry.sh
index 857168d6c3..44d37b9dbf 100755
--- a/libs/lumier/src/bin/entry.sh
+++ b/libs/lumier/src/bin/entry.sh
@@ -1,7 +1,13 @@
#!/usr/bin/env bash
-# Exit on errors, undefined variables, and propagate errors in pipes
-set -euo pipefail
+# Configure SSH to prevent known hosts warnings
+export SSHPASS_PROMPT=
+export SSH_ASKPASS=/bin/echo
+# Set SSH quiet mode via the SSHPASS environment variable
+export SSHPASS_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -q"
+
+# We'll enable strict error checking AFTER initialization
+# to prevent premature exits
# Source configuration files
CONFIG_DIR="/run/config"
@@ -25,22 +31,30 @@ if [ -z "${VM_NAME:-}" ]; then
export VM_NAME
fi
-# Set HOST_STORAGE_PATH to /storage/$VM_NAME if not set
+# Set HOST_STORAGE_PATH to a macOS ephemeral path if not set
if [ -z "${HOST_STORAGE_PATH:-}" ]; then
- HOST_STORAGE_PATH="/storage/$VM_NAME"
+ # Use macOS /private/tmp directory which gets automatically cleaned
+ # This is the proper temporary directory on macOS that's regularly purged
+ HOST_STORAGE_PATH="/private/tmp/lumier_storage"
+
+ # Tell user that ephemeral storage is being used
+ echo "Using ephemeral storage at ${HOST_STORAGE_PATH}. VM state will be lost when macOS cleans up temporary files."
+
export HOST_STORAGE_PATH
fi
-# Optionally check for mountpoints
-if mountpoint -q /storage; then
- echo "/storage is mounted"
-fi
-if mountpoint -q /shared; then
- echo "/shared is mounted"
+# Only check and report mountpoints in debug mode
+if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ if mountpoint -q /storage; then
+ echo "/storage is mounted"
+ fi
+ if mountpoint -q /shared; then
+ echo "/shared is mounted"
+ fi
+ # if mountpoint -q /data; then
+ # echo "/data is mounted"
+ # fi
fi
-# if mountpoint -q /data; then
-# echo "/data is mounted"
-# fi
# Log startup info
echo "Lumier VM is starting..."
@@ -49,8 +63,31 @@ echo "Lumier VM is starting..."
cleanup() {
set +e # Don't exit on error in cleanup
echo "[cleanup] Caught signal, shutting down..."
- echo "[cleanup] Stopping VM..."
- stop_vm true
+
+ # Check if we're in the middle of an image pull
+ if [[ "$PULL_IN_PROGRESS" == "1" ]]; then
+ echo "[cleanup] Interrupted during image pull, skipping VM stop."
+ else
+ echo "[cleanup] Stopping VM..."
+ stop_vm true
+ fi
+
+ # Attempt to clean up ephemeral storage if it's in the /private/tmp directory
+ if [[ "$HOST_STORAGE_PATH" == "/private/tmp/lumier_"* ]]; then
+ echo "[cleanup] Checking if VM exists before cleanup..."
+
+ # First check if VM actually exists
+ VM_INFO=$(lume_get "$VM_NAME" "$HOST_STORAGE_PATH" "json" "false")
+
+ # Only try VM deletion if VM exists and not in the middle of a pull
+ if [[ "$PULL_IN_PROGRESS" != "1" && $VM_INFO != *"Virtual machine not found"* ]]; then
+ echo "[cleanup] Removing VM and storage using API: $HOST_STORAGE_PATH"
+ lume_delete "$VM_NAME" "$HOST_STORAGE_PATH" > /dev/null 2>&1
+ else
+ echo "[cleanup] No VM found or pull was interrupted, skipping API deletion"
+ fi
+ fi
+
# Now gently stop noVNC proxy if running
# if [ -n "${NOVNC_PID:-}" ] && kill -0 "$NOVNC_PID" 2>/dev/null; then
# echo "[cleanup] Stopping noVNC proxy (PID $NOVNC_PID)..."
@@ -74,17 +111,26 @@ cleanup() {
}
trap cleanup SIGTERM SIGINT
-# Start the VM
-start_vm
+# Now enable strict error handling after initialization
+set -euo pipefail
+
+# Start the VM with error handling
+if ! start_vm; then
+ echo "ERROR: Failed to start VM!" >&2
+ exit 1
+fi
# Start noVNC for VNC access
NOVNC_PID=""
if [ -n "${VNC_PORT:-}" ] && [ -n "${VNC_PASSWORD:-}" ]; then
- echo "Starting noVNC proxy with optimized color settings..."
+ # Only show this in debug mode
+ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ echo "Starting noVNC proxy with optimized color settings..."
+ fi
${NOVNC_PATH}/utils/novnc_proxy --vnc host.docker.internal:${VNC_PORT} --listen 8006 --web ${NOVNC_PATH} > /dev/null 2>&1 &
NOVNC_PID=$!
disown $NOVNC_PID
- echo "noVNC interface available at: http://localhost:8006/vnc.html?password=${VNC_PASSWORD}&autoconnect=true&logging=debug"
+ echo "noVNC interface available at: http://localhost:PORT/vnc.html?password=${VNC_PASSWORD}&autoconnect=true (replace PORT with the port you forwarded to 8006)"
fi
echo "Lumier is running. Press Ctrl+C to stop."
diff --git a/libs/lumier/src/hooks/on-logon.sh b/libs/lumier/src/hooks/on-logon.sh
index 9b9d2e5202..39f4b41d0f 100755
--- a/libs/lumier/src/hooks/on-logon.sh
+++ b/libs/lumier/src/hooks/on-logon.sh
@@ -10,12 +10,22 @@ HOST_SHARED_PATH="$2"
# Define the path to the user's optional on-logon script within the shared folder
USER_ON_LOGON_SCRIPT_PATH="$HOST_SHARED_PATH/lifecycle/on-logon.sh"
-echo "[Remote] Lumier entry point script starting..."
-echo "[Remote] Checking for user script at: $USER_ON_LOGON_SCRIPT_PATH"
+# Set default value for VNC_DEBUG if not provided
+VNC_DEBUG=${VNC_DEBUG:-0}
+
+# Only show debug logs if VNC_DEBUG is enabled
+if [ "$VNC_DEBUG" = "1" ]; then
+ echo "[Remote] Lumier entry point script starting..."
+ echo "[Remote] Checking for user script at: $USER_ON_LOGON_SCRIPT_PATH"
+fi
# Check if the user-provided script exists
if [ -f "$USER_ON_LOGON_SCRIPT_PATH" ]; then
- echo "[Remote] Found user script. Making executable and running..."
+ # Only show debug logs if VNC_DEBUG is enabled
+ if [ "$VNC_DEBUG" = "1" ]; then
+ echo "[Remote] Found user script. Making executable and running..."
+ fi
+
chmod +x "$USER_ON_LOGON_SCRIPT_PATH"
# Execute the user script in a subshell, passing VNC password and shared path as arguments
@@ -23,15 +33,25 @@ if [ -f "$USER_ON_LOGON_SCRIPT_PATH" ]; then
# Capture exit code (optional, but good practice)
USER_SCRIPT_EXIT_CODE=$?
- echo "[Remote] User script finished with exit code: $USER_SCRIPT_EXIT_CODE."
+
+ # Only show debug logs if VNC_DEBUG is enabled
+ if [ "$VNC_DEBUG" = "1" ]; then
+ echo "[Remote] User script finished with exit code: $USER_SCRIPT_EXIT_CODE."
+ fi
# Propagate the exit code if non-zero (optional)
# if [ $USER_SCRIPT_EXIT_CODE -ne 0 ]; then
# exit $USER_SCRIPT_EXIT_CODE
# fi
else
- echo "[Remote] No user-provided on-logon script found at $USER_ON_LOGON_SCRIPT_PATH. Skipping."
+ # Only show debug logs if VNC_DEBUG is enabled
+ if [ "$VNC_DEBUG" = "1" ]; then
+ echo "[Remote] No user-provided on-logon script found at $USER_ON_LOGON_SCRIPT_PATH. Skipping."
+ fi
fi
-echo "[Remote] Lumier entry point script finished."
+# Only show debug logs if VNC_DEBUG is enabled
+if [ "$VNC_DEBUG" = "1" ]; then
+ echo "[Remote] Lumier entry point script finished."
+fi
exit 0 # Ensure the entry point script exits cleanly if no user script or user script succeeded
diff --git a/libs/lumier/src/lib/utils.sh b/libs/lumier/src/lib/utils.sh
index 9f4b22629a..2c61acb89f 100755
--- a/libs/lumier/src/lib/utils.sh
+++ b/libs/lumier/src/lib/utils.sh
@@ -8,12 +8,16 @@ wait_for_ssh() {
local retry_interval=${4:-5} # Default retry interval is 5 seconds
local max_retries=${5:-20} # Default maximum retries is 20 (0 for infinite)
- echo "Waiting for SSH to become available on $host_ip..."
+ # Only show waiting message in debug mode
+ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ echo "Waiting for SSH to become available on $host_ip..."
+ fi
local retry_count=0
while true; do
# Try to connect via SSH
- sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$host_ip" "exit"
+ # Add -q for completely silent operation, redirect stderr to /dev/null
+ sshpass -p "$password" ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "$user@$host_ip" "exit" 2>/dev/null
# Check the exit status of the SSH command
if [ $? -eq 0 ]; then
@@ -30,7 +34,10 @@ wait_for_ssh() {
return 1
fi
- echo "SSH not ready. Retrying in $retry_interval seconds... (Attempt $retry_count)"
+ # Only show retry messages in debug mode
+ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ echo "SSH not ready. Retrying in $retry_interval seconds... (Attempt $retry_count)"
+ fi
sleep $retry_interval
done
}
@@ -50,12 +57,18 @@ execute_remote_script() {
return 1
fi
- echo "VNC password exported to VM: $vnc_password"
+ # Only show VNC info in debug mode
+ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ echo "VNC password exported to VM: $vnc_password"
+ fi
# Set a default mount point for data in the VM if data_folder is provided
if [ -n "$data_folder" ]; then
shared_folder_path="/Volumes/My Shared Files"
- echo "Data folder path in VM: $shared_folder_path"
+ # Only show path in debug mode
+ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ echo "Data folder path in VM: $shared_folder_path"
+ fi
else
shared_folder_path=""
fi
@@ -68,26 +81,38 @@ execute_remote_script() {
if [ -n "$shared_folder_path" ]; then
script_content+="export SHARED_FOLDER_PATH='$shared_folder_path'\n"
fi
+ # Pass debug setting to the VM
+ script_content+="export VNC_DEBUG='${LUMIER_DEBUG:-0}'\n"
- # Add debug message to the script to confirm it's being run
- script_content+="echo \"[DEBUG] Starting on-logon script execution...\"\n"
+ # Add debug messages only if debug mode is enabled
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ script_content+="echo \"[DEBUG] Starting on-logon script execution...\"\n"
+ fi
# Add the original script content
script_content+="$(<"$script_path")"
- # Add more debug messages after script execution
- script_content+="\necho \"[DEBUG] Finished executing on-logon script.\"\n"
+ # Add debug messages only if debug mode is enabled
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ script_content+="\necho \"[DEBUG] Finished executing on-logon script.\"\n"
+ fi
- # Print debug info to the docker logs
- echo "[DEBUG] Executing remote script with content length: $(echo -n "$script_content" | wc -c) bytes"
- echo "[DEBUG] Script path: $script_path"
+ # Print debug info only when debug mode is enabled
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ echo "[DEBUG] Executing remote script with content length: $(echo -n "$script_content" | wc -c) bytes"
+ echo "[DEBUG] Script path: $script_path"
+ fi
# Use a here-document to send the script content
- sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$host" "bash -s -- '$vnc_password' '$data_folder'" <<EOF
+ # Add -q for completely silent operation, redirect stderr to /dev/null
+ sshpass -p "$password" ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "$user@$host" "bash -s -- '$vnc_password' '$data_folder'" 2>/dev/null <<EOF
$script_content
EOF
- echo "[DEBUG] Script execution completed."
+ # Print completion message only in debug mode
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ echo "[DEBUG] Script execution completed."
+ fi
# Check the exit status of the sshpass command
if [ $? -ne 0 ]; then
diff --git a/libs/lumier/src/lib/vm.sh b/libs/lumier/src/lib/vm.sh
index a2a5a68f36..ecdbf8bad0 100755
--- a/libs/lumier/src/lib/vm.sh
+++ b/libs/lumier/src/lib/vm.sh
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
+# Initialize global flags
+export PULL_IN_PROGRESS=0
+
start_vm() {
# Determine storage path for VM
STORAGE_PATH="$HOST_STORAGE_PATH"
@@ -7,9 +10,8 @@ start_vm() {
STORAGE_PATH="storage_${VM_NAME}"
fi
- # Check if VM exists and its status using JSON format
- VM_INFO=$(lume_get "$VM_NAME" "$STORAGE_PATH")
- echo "VM_INFO: $VM_INFO"
+ # Check if VM exists and its status using JSON format - quietly
+ VM_INFO=$(lume_get "$VM_NAME" "$STORAGE_PATH" "json" "${LUMIER_DEBUG:-0}")
# Check if VM not found error
if [[ $VM_INFO == *"Virtual machine not found"* ]]; then
@@ -18,7 +20,7 @@ start_vm() {
REGISTRY=$(echo $VERSION | cut -d'/' -f1)
ORGANIZATION=$(echo $VERSION | cut -d'/' -f2)
- echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] INFO: Pulling VM image $IMAGE_NAME from $REGISTRY/$ORGANIZATION to $STORAGE_PATH"
+ echo "Pulling VM image $IMAGE_NAME..."
lume_pull "$IMAGE_NAME" "$VM_NAME" "$STORAGE_PATH" "$REGISTRY" "$ORGANIZATION"
else
# Parse the JSON status - check if it contains "status" : "running"
@@ -33,12 +35,14 @@ start_vm() {
MEMORY_DISPLAY="${RAM_SIZE}MB"
fi
- # Set VM parameters using the new wrapper function
- echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] INFO: Updating VM settings cpu=$CPU_CORES name=$VM_NAME location=$STORAGE_PATH display=$DISPLAY memory=$MEMORY_DISPLAY disk_size=unchanged"
+ # Set VM parameters using the wrapper function
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "Updating VM settings: cpu=$CPU_CORES memory=$MEMORY_DISPLAY display=$DISPLAY"
+ fi
lume_set "$VM_NAME" "$STORAGE_PATH" "$CPU_CORES" "$RAM_SIZE" "$DISPLAY"
- # Fetch VM configuration
- CONFIG_JSON=$(lume_get "$VM_NAME" "$STORAGE_PATH")
+ # Fetch VM configuration - quietly (don't display to console)
+ CONFIG_JSON=$(lume_get "$VM_NAME" "$STORAGE_PATH" "json" "${LUMIER_DEBUG:-0}")
# Setup shared directory args if necessary
SHARED_DIR_ARGS=""
@@ -63,10 +67,8 @@ start_vm() {
attempt=0
while [ $attempt -lt $max_attempts ]; do
- # Get VM info as JSON using the API function
- VM_INFO=$(lume_get "$VM_NAME" "$STORAGE_PATH")
- # VM_INFO=$(lume get "$VM_NAME" --storage "$STORAGE_PATH" -f json 2>/dev/null)
- echo "VM_INFO: $VM_INFO"
+ # Get VM info as JSON using the API function - pass debug flag
+ VM_INFO=$(lume_get "$VM_NAME" "$STORAGE_PATH" "json" "${LUMIER_DEBUG:-0}")
# Extract status, IP address, and VNC URL using the helper function
vm_status=$(extract_json_field "status" "$VM_INFO")
@@ -103,7 +105,9 @@ start_vm() {
# Execute on-logon.sh if present
on_logon_script="/run/lifecycle/on-logon.sh"
# Use HOST_SHARED_PATH which is set earlier in the script
- echo "Executing on-logon.sh on VM..."
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ echo "Executing on-logon.sh on VM..."
+ fi
execute_remote_script "$vm_ip" "$HOST_USER" "$HOST_PASSWORD" "$on_logon_script" "$VNC_PASSWORD" "$HOST_SHARED_PATH"
}
@@ -133,8 +137,10 @@ lume_get() {
echo "[DEBUG] Full curl command: $curl_cmd"
fi
- # Always log the curl command before sending
- echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] INFO: Executing curl request: $api_url" >&2
+ # Log curl commands only when in debug mode
+ if [[ "$debug" == "true" || "$LUMIER_DEBUG" == "1" ]]; then
+ echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] DEBUG: Executing curl request: $api_url" >&2
+ fi
# Make the API call
local response=$(curl --connect-timeout 6000 \
@@ -143,12 +149,12 @@ lume_get() {
"$api_url")
# Print the response if debugging is enabled
- if [[ "$debug" == "true" || "$LUMIER_DEBUG" == "1" ]]; then
+ if [[ "$debug" == "true" || "${LUMIER_DEBUG:-0}" == "1" ]]; then
echo "[DEBUG] API Response:"
echo "$response" | jq '.' 2>/dev/null || echo "$response"
fi
- # Output the response
+ # Output the response so callers can capture it
echo "$response"
}
@@ -172,9 +178,13 @@ lume_set() {
memory="$(awk "BEGIN { printf \"%.1f\", $memory/1024 }")GB"
fi
- echo "[DEBUG] Formatted memory value: $memory"
+ # Only show memory formatting debug in debug mode
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "[DEBUG] Formatted memory value: $memory"
+ fi
- curl --connect-timeout 6000 \
+ # Store response to conditionally show based on debug mode
+ local response=$(curl --connect-timeout 6000 \
--max-time 5000 \
-s \
-X PATCH \
@@ -185,22 +195,29 @@ lume_set() {
\"display\": \"$display\",
\"storage\": \"$storage\"
}" \
- "http://${api_host}:${api_port}/lume/vms/${vm_name}"
+ "http://${api_host}:${api_port}/lume/vms/${vm_name}")
+
+ # Only show response in debug mode
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ echo "$response"
+ fi
}
stop_vm() {
local in_cleanup=${1:-false} # Optional first argument to indicate if called from cleanup trap
echo "Stopping VM '$VM_NAME'..."
STORAGE_PATH="$HOST_STORAGE_PATH"
- echo "STORAGE_PATH: $STORAGE_PATH"
- VM_INFO=$(lume_get "$VM_NAME" "$STORAGE_PATH")
+ # Only show storage path in debug mode
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "STORAGE_PATH: $STORAGE_PATH"
+ fi
+
+ VM_INFO=$(lume_get "$VM_NAME" "$STORAGE_PATH" "json" "${LUMIER_DEBUG:-0}")
vm_status=$(extract_json_field "status" "$VM_INFO")
if [ "$vm_status" == "running" ]; then
- echo "VM '$VM_NAME' status is 'running'. Attempting stop."
lume_stop "$VM_NAME" "$STORAGE_PATH"
- echo "VM '$VM_NAME' stop command issued."
elif [ "$vm_status" == "stopped" ]; then
echo "VM '$VM_NAME' is already stopped."
elif [ "$in_cleanup" = true ]; then
@@ -231,12 +248,36 @@ is_vm_running() {
lume_stop() {
local vm_name="$1"
local storage="$2"
- curl --connect-timeout 6000 \
- --max-time 5000 \
- -X POST \
- -H "Content-Type: application/json" \
- -d '{"storage":"'$storage'"}' \
- "http://host.docker.internal:3000/lume/vms/${vm_name}/stop"
+
+ local api_host="${LUME_API_HOST:-host.docker.internal}"
+ local api_port="${LUME_API_PORT:-3000}"
+
+ # Only log in debug mode
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "Stopping VM $vm_name..."
+ fi
+
+ # Execute command and capture response
+ local response
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ # Show output in debug mode
+ response=$(curl --connect-timeout 6000 \
+ --max-time 5000 \
+ -X POST \
+ -H "Content-Type: application/json" \
+ -d '{"storage":"'$storage'"}' \
+ "http://${api_host}:${api_port}/lume/vms/${vm_name}/stop")
+ echo "$response"
+ else
+ # Run silently in normal mode
+ response=$(curl --connect-timeout 6000 \
+ --max-time 5000 \
+ -s \
+ -X POST \
+ -H "Content-Type: application/json" \
+ -d '{"storage":"'$storage'"}' \
+ "http://${api_host}:${api_port}/lume/vms/${vm_name}/stop")
+ fi
}
# Pull a VM image using curl
@@ -250,22 +291,53 @@ lume_pull() {
local api_host="${LUME_API_HOST:-host.docker.internal}"
local api_port="${LUME_API_PORT:-3000}"
- echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] INFO: Pulling image $image from $registry/$organization to $storage"
+ # Mark that pull is in progress for interrupt handling
+ export PULL_IN_PROGRESS=1
- # Pull image via API
- curl --connect-timeout 6000 \
- --max-time 5000 \
- -s \
- -X POST \
- -H "Content-Type: application/json" \
- -d "{
- \"image\": \"$image\",
- \"name\": \"$vm_name\",
- \"registry\": \"$registry\",
- \"organization\": \"$organization\",
- \"storage\": \"$storage\"
- }" \
- "http://${api_host}:${api_port}/lume/pull"
+ # Only log full details in debug mode
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "Pulling image $image from $registry/$organization..."
+ else
+ echo "Pulling image $image..."
+ fi
+
+ # Inform users how to check pull progress
+ echo "You can check the pull progress using: lume logs -f"
+
+ # Pull image via API and capture response
+ local response
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ # Show full response in debug mode - no timeout limits
+ response=$(curl \
+ -X POST \
+ -H "Content-Type: application/json" \
+ -d "{
+ \"image\": \"$image\",
+ \"name\": \"$vm_name\",
+ \"registry\": \"$registry\",
+ \"organization\": \"$organization\",
+ \"storage\": \"$storage\"
+ }" \
+ "http://${api_host}:${api_port}/lume/pull")
+ echo "$response"
+ else
+ # Run silently in normal mode - no timeout limits
+ response=$(curl \
+ -s \
+ -X POST \
+ -H "Content-Type: application/json" \
+ -d "{
+ \"image\": \"$image\",
+ \"name\": \"$vm_name\",
+ \"registry\": \"$registry\",
+ \"organization\": \"$organization\",
+ \"storage\": \"$storage\"
+ }" \
+ "http://${api_host}:${api_port}/lume/pull")
+ fi
+
+ # Unset pull in progress flag
+ export PULL_IN_PROGRESS=0
}
@@ -273,7 +345,7 @@ lume_pull() {
lume_run() {
# Parse args
local shared_dir=""
- local storage="ssd"
+ local storage=""
local vm_name="lume_vm"
local no_display=true
while [[ $# -gt 0 ]]; do
@@ -298,17 +370,88 @@ lume_run() {
esac
done
- # Default to ~/Projects if not provided
- if [[ -z "$shared_dir" ]]; then
- shared_dir="~/Projects"
+ local api_host="${LUME_API_HOST:-host.docker.internal}"
+ local api_port="${LUME_API_PORT:-3000}"
+
+ # Only log in debug mode
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "Running VM $vm_name..."
+ fi
+
+ # Build the JSON body dynamically based on what's provided
+ local json_body="{\"noDisplay\": true"
+
+ # Only include shared directories if shared_dir is provided
+ if [[ -n "$shared_dir" ]]; then
+ json_body+=", \"sharedDirectories\": [{\"hostPath\": \"$shared_dir\", \"readOnly\": false}]"
fi
- local json_body="{\"noDisplay\": true, \"sharedDirectories\": [{\"hostPath\": \"$shared_dir\", \"readOnly\": false}], \"storage\": \"$storage\", \"recoveryMode\": false}"
- local curl_cmd="curl --connect-timeout 6000 \
- --max-time 5000 \
- -X POST \
- -H 'Content-Type: application/json' \
- -d '$json_body' \
- http://host.docker.internal:3000/lume/vms/$vm_name/run"
- eval "$curl_cmd"
+ # Only include storage if it's provided
+ if [[ -n "$storage" ]]; then
+ json_body+=", \"storage\": \"$storage\""
+ fi
+
+ # Add recovery mode (always false)
+ json_body+=", \"recoveryMode\": false}"
+
+ # Execute the command and store the response
+ local response
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ # Show response in debug mode
+ response=$(curl --connect-timeout 6000 \
+ --max-time 5000 \
+ -X POST \
+ -H 'Content-Type: application/json' \
+ -d "$json_body" \
+ http://${api_host}:${api_port}/lume/vms/$vm_name/run)
+ echo "$response"
+ else
+ # Run silently in normal mode
+ response=$(curl --connect-timeout 6000 \
+ --max-time 5000 \
+ -s \
+ -X POST \
+ -H 'Content-Type: application/json' \
+ -d "$json_body" \
+ http://${api_host}:${api_port}/lume/vms/$vm_name/run)
+ fi
+}
+
+# Delete a VM using curl
+lume_delete() {
+ local vm_name="$1"
+ local storage="$2"
+
+ local api_host="${LUME_API_HOST:-host.docker.internal}"
+ local api_port="${LUME_API_PORT:-3000}"
+
+ # URL encode the storage path for the query parameter
+ # Replace special characters with their URL encoded equivalents
+ local encoded_storage=$(echo "$storage" | sed 's/\//%2F/g' | sed 's/ /%20/g' | sed 's/:/%3A/g')
+
+ # Construct API URL with encoded storage parameter
+ local api_url="http://${api_host}:${api_port}/lume/vms/${vm_name}?storage=${encoded_storage}"
+
+ # Only log in debug mode
+ if [[ "$LUMIER_DEBUG" == "1" ]]; then
+ echo "Deleting VM $vm_name from storage $storage..."
+ fi
+
+ # Execute command and capture response
+ local response
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ # Show output in debug mode
+ response=$(curl --connect-timeout 6000 \
+ --max-time 5000 \
+ -X DELETE \
+ "$api_url")
+ echo "$response"
+ else
+ # Run silently in normal mode
+ response=$(curl --connect-timeout 6000 \
+ --max-time 5000 \
+ -s \
+ -X DELETE \
+ "$api_url")
+ fi
}
\ No newline at end of file