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.

Fix shared on-logon.sh execution

f-trycua7a687af98fdf
diff --git a/libs/lumier/README.md b/libs/lumier/README.md
index 544e27bf8b..826d509763 100644
--- a/libs/lumier/README.md
+++ b/libs/lumier/README.md
@@ -118,6 +118,41 @@ docker run -it --rm \
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.
+## Automating VM Startup with on-logon.sh
+
+You can automatically run scripts when the VM starts up by placing an `on-logon.sh` script in the shared folder's lifecycle directory. This is useful for setting up your VM environment each time it starts.
+
+```bash
+# Create the lifecycle directory in your shared folder
+mkdir -p shared/lifecycle
+
+# Create a sample on-logon.sh script
+cat > shared/lifecycle/on-logon.sh << 'EOF'
+#!/usr/bin/env bash
+
+# Create a file on the desktop
+echo "Hello from Lumier!" > /Users/lume/Desktop/hello_lume.txt
+
+# You can add more commands to execute at VM startup
+# For example:
+# - Configure environment variables
+# - Start applications
+# - Mount network drives
+# - Set up development environments
+EOF
+
+# Make the script executable
+chmod +x shared/lifecycle/on-logon.sh
+```
+
+The script will be automatically executed when the VM starts up. It runs in the VM context and has access to:
+
+- The `/Users/lume` user directory (home directory in the VM)
+- The shared folder at `/Volumes/My Shared Files` inside the VM
+- Any resources available to the VM
+
+This feature enables automation of VM setup without modifying the base VM image.
+
## Using Docker Compose
You can also use Docker Compose to run Lumier with a simple configuration file. Create a `docker-compose.yml` file with the following content:
diff --git a/libs/lumier/src/bin/entry.sh b/libs/lumier/src/bin/entry.sh
index 6081a17ea2..c9cd2f0fbf 100755
--- a/libs/lumier/src/bin/entry.sh
+++ b/libs/lumier/src/bin/entry.sh
@@ -112,7 +112,7 @@ if [ -n "${VNC_PORT:-}" ] && [ -n "${VNC_PASSWORD:-}" ]; then
${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:PORT/vnc.html?password=${VNC_PASSWORD}&autoconnect=true (replace PORT with the port you forwarded to 8006)"
+ echo "noVNC interface available at: http://localhost:8006/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 39f4b41d0f..94cdbcca9c 100755
--- a/libs/lumier/src/hooks/on-logon.sh
+++ b/libs/lumier/src/hooks/on-logon.sh
@@ -5,53 +5,56 @@
# $2: HOST_SHARED_PATH (Path inside VM where host shared dir is mounted, e.g., /Volumes/My Shared Files)
VNC_PASSWORD="$1"
-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"
+# IMPORTANT: In the VM, the shared folder is always mounted at this fixed location
+HOST_SHARED_PATH="/Volumes/My Shared Files"
# Set default value for VNC_DEBUG if not provided
VNC_DEBUG=${VNC_DEBUG:-0}
-# Only show debug logs if VNC_DEBUG is enabled
+# 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"
+
+# Show basic information when 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"
+ echo "[VM] Lumier lifecycle script starting"
+ echo "[VM] Looking for user script: $USER_ON_LOGON_SCRIPT_PATH"
fi
# Check if the user-provided script exists
if [ -f "$USER_ON_LOGON_SCRIPT_PATH" ]; then
- # Only show debug logs if VNC_DEBUG is enabled
if [ "$VNC_DEBUG" = "1" ]; then
- echo "[Remote] Found user script. Making executable and running..."
+ echo "[VM] Found user script: $USER_ON_LOGON_SCRIPT_PATH"
fi
+ # Always show what script we're executing
+ echo "[VM] Executing user lifecycle script"
+
+ # Make script executable
chmod +x "$USER_ON_LOGON_SCRIPT_PATH"
-
- # Execute the user script in a subshell, passing VNC password and shared path as arguments
- "$USER_ON_LOGON_SCRIPT_PATH" "$VNC_PASSWORD" "$HOST_SHARED_PATH"
-
- # Capture exit code (optional, but good practice)
+
+ # Execute the user script in a subshell with error output captured
+ "$USER_ON_LOGON_SCRIPT_PATH" "$VNC_PASSWORD" "$HOST_SHARED_PATH" 2>&1
+
+ # Capture exit code
USER_SCRIPT_EXIT_CODE=$?
- # Only show debug logs if VNC_DEBUG is enabled
+ # Always report script execution results
+ if [ $USER_SCRIPT_EXIT_CODE -eq 0 ]; then
+ echo "[VM] User lifecycle script completed successfully"
+ else
+ echo "[VM] User lifecycle script failed with exit code: $USER_SCRIPT_EXIT_CODE"
+ fi
+
+ # Check results (only in debug mode)
if [ "$VNC_DEBUG" = "1" ]; then
- echo "[Remote] User script finished with exit code: $USER_SCRIPT_EXIT_CODE."
+ # List any files created by the script
+ echo "[VM] Files created by user script:"
+ ls -la /Users/lume/Desktop/hello_*.txt 2>/dev/null || echo "[VM] No script-created files found"
fi
-
- # Propagate the exit code if non-zero (optional)
- # if [ $USER_SCRIPT_EXIT_CODE -ne 0 ]; then
- # exit $USER_SCRIPT_EXIT_CODE
- # fi
else
- # 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."
+ echo "[VM] No user lifecycle script found"
fi
fi
-# 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
+exit 0 # Ensure the entry point script exits cleanly
diff --git a/libs/lumier/src/lib/utils.sh b/libs/lumier/src/lib/utils.sh
index 2c61acb89f..8a9937548f 100755
--- a/libs/lumier/src/lib/utils.sh
+++ b/libs/lumier/src/lib/utils.sh
@@ -62,9 +62,11 @@ execute_remote_script() {
echo "VNC password exported to VM: $vnc_password"
fi
- # Set a default mount point for data in the VM if data_folder is provided
+ # Set the shared folder path for the VM
if [ -n "$data_folder" ]; then
+ # VM always sees shared folders at this path, regardless of container path
shared_folder_path="/Volumes/My Shared Files"
+
# Only show path in debug mode
if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
echo "Data folder path in VM: $shared_folder_path"
@@ -104,10 +106,18 @@ execute_remote_script() {
fi
# Use a here-document to send the script content
- # 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
+ # We'll capture both stdout and stderr when debug is enabled
+ if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
+ echo "[DEBUG] Connecting to $user@$host to execute script..."
+ sshpass -p "$password" ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "$user@$host" "bash -s -- '$vnc_password' '$data_folder'" 2>&1 <<EOF
+$script_content
+EOF
+ else
+ # Otherwise run quietly
+ 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
+ fi
# Print completion message only in debug mode
if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
diff --git a/libs/lumier/src/lib/vm.sh b/libs/lumier/src/lib/vm.sh
index ecdbf8bad0..5437976701 100755
--- a/libs/lumier/src/lib/vm.sh
+++ b/libs/lumier/src/lib/vm.sh
@@ -104,11 +104,19 @@ 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
- if [[ "${LUMIER_DEBUG:-0}" == "1" ]]; then
- echo "Executing on-logon.sh on VM..."
+
+ # Only show detailed logs in debug mode
+ if [ "${LUMIER_DEBUG:-0}" == "1" ]; then
+ echo "Running on-logon.sh hook script on VM..."
+ fi
+
+ # Check if script exists
+ if [ ! -f "$on_logon_script" ]; then
+ echo "Warning: on-logon.sh hook script not found at $on_logon_script"
+ else
+ # Execute the remote script
+ execute_remote_script "$vm_ip" "$HOST_USER" "$HOST_PASSWORD" "$on_logon_script" "$VNC_PASSWORD" "$HOST_SHARED_PATH"
fi
- execute_remote_script "$vm_ip" "$HOST_USER" "$HOST_PASSWORD" "$on_logon_script" "$VNC_PASSWORD" "$HOST_SHARED_PATH"
}
# Get VM information using curl