From 31a238016efcd9a4708e01e945f60e4d40c9ddd6 Mon Sep 17 00:00:00 2001 From: f-trycua Date: Fri, 25 Apr 2025 15:34:56 -0700 Subject: [PATCH 1/2] Update lume install location --- libs/lume/scripts/install.sh | 68 +++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/libs/lume/scripts/install.sh b/libs/lume/scripts/install.sh index 66a4d059..aa0529c6 100755 --- a/libs/lume/scripts/install.sh +++ b/libs/lume/scripts/install.sh @@ -10,25 +10,75 @@ NORMAL=$(tput sgr0) RED=$(tput setaf 1) GREEN=$(tput setaf 2) BLUE=$(tput setaf 4) +YELLOW=$(tput setaf 3) -# Default installation directory -DEFAULT_INSTALL_DIR="/usr/local/bin" +# Default installation directory (user-specific, doesn't require sudo) +DEFAULT_INSTALL_DIR="$HOME/.local/bin" INSTALL_DIR="${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}" # GitHub info GITHUB_REPO="trycua/cua" LATEST_RELEASE_URL="https://api.github.com/repos/$GITHUB_REPO/releases/latest" +# Parse command line arguments +while [ "$#" -gt 0 ]; do + case "$1" in + --install-dir=*) + INSTALL_DIR="${1#*=}" + ;; + --help) + echo "${BOLD}${BLUE}Lume 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/lume $0 # Install to /opt/lume (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}Lume Installer${NORMAL}" echo "This script will install Lume to your system." # Check if we're running with appropriate permissions check_permissions() { - if [ "$INSTALL_DIR" = "$DEFAULT_INSTALL_DIR" ] && [ "$(id -u)" != "0" ]; then - echo "${RED}Error: Installing to $INSTALL_DIR requires root privileges.${NORMAL}" - echo "Please run with sudo or specify a different directory with INSTALL_DIR environment variable." - echo "Example: INSTALL_DIR=\$HOME/.local/bin $0" - exit 1 + # 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 } @@ -123,8 +173,8 @@ install_binary() { # Check if the installation directory is in PATH if [ -n "${PATH##*$INSTALL_DIR*}" ]; then - echo "${RED}Warning: $INSTALL_DIR is not in your PATH.${NORMAL}" - echo "You may need to add it to your shell profile:" + 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" From 8dfc3781b9a503555757ef617a822200fbcd285b Mon Sep 17 00:00:00 2001 From: f-trycua Date: Sat, 26 Apr 2025 12:10:50 -0700 Subject: [PATCH 2/2] Remove sudo from readme --- README.md | 4 ++-- notebooks/computer_nb.ipynb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0fe35540..1f80e3c7 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ If you only need the virtualization capabilities: ```bash -sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)" +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)" ``` For Lume usage instructions, refer to the [Lume documentation](./libs/lume/README.md). @@ -54,7 +54,7 @@ If you want to use AI agents with virtualized environments: 1. Install the Lume CLI: ```bash - sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)" ``` 2. Pull the latest macOS CUA image: diff --git a/notebooks/computer_nb.ipynb b/notebooks/computer_nb.ipynb index 0a26b7e6..c951a1e4 100644 --- a/notebooks/computer_nb.ipynb +++ b/notebooks/computer_nb.ipynb @@ -67,7 +67,7 @@ "For installing the standalone lume binary, run the following command from a terminal:\n", "\n", "```bash\n", - "sudo /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)\"\n", + "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)\"\n", "```" ] },