diff --git a/libs/lume/scripts/install.sh b/libs/lume/scripts/install.sh index d854c0e4..4c1efdc9 100755 --- a/libs/lume/scripts/install.sh +++ b/libs/lume/scripts/install.sh @@ -20,24 +20,32 @@ INSTALL_DIR="${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}" GITHUB_REPO="trycua/cua" LATEST_RELEASE_URL="https://api.github.com/repos/$GITHUB_REPO/releases/latest" +# Option to skip background service setup (default: install it) +INSTALL_BACKGROUND_SERVICE=true + # Parse command line arguments while [ "$#" -gt 0 ]; do case "$1" in --install-dir=*) INSTALL_DIR="${1#*=}" ;; + --no-background-service|--skip-background-service) + INSTALL_BACKGROUND_SERVICE=false + ;; --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 " --install-dir=DIR Install to the specified directory (default: $DEFAULT_INSTALL_DIR)" + echo " --no-background-service Do not setup the Lume background service (LaunchAgent)" + 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)" + echo " $0 # Install to $DEFAULT_INSTALL_DIR and setup background service" + echo " $0 --install-dir=/usr/local/bin # Install to system directory (may require root privileges)" + echo " $0 --no-background-service # Install without setting up the background service" + echo " INSTALL_DIR=/opt/lume $0 # Install to /opt/lume (legacy env var support)" exit 0 ;; *) @@ -207,25 +215,26 @@ main() { echo "${GREEN}${BOLD}Lume has been successfully installed!${NORMAL}" echo "Run ${BOLD}lume${NORMAL} to get started." - # --- LaunchAgent setup for lume daemon --- - SERVICE_NAME="com.trycua.lume_daemon" - PLIST_PATH="$HOME/Library/LaunchAgents/$SERVICE_NAME.plist" - LUME_BIN="$INSTALL_DIR/lume" + if [ "$INSTALL_BACKGROUND_SERVICE" = true ]; then + # --- Setup background service (LaunchAgent) for Lume --- + SERVICE_NAME="com.trycua.lume_daemon" + PLIST_PATH="$HOME/Library/LaunchAgents/$SERVICE_NAME.plist" + LUME_BIN="$INSTALL_DIR/lume" - echo "" - echo "Setting up LaunchAgent to run lume daemon on login..." + echo "" + echo "Setting up LaunchAgent to run lume daemon on login..." - # Create LaunchAgents directory if it doesn't exist - mkdir -p "$HOME/Library/LaunchAgents" + # Create LaunchAgents directory if it doesn't exist + mkdir -p "$HOME/Library/LaunchAgents" - # Unload existing service if present - if [ -f "$PLIST_PATH" ]; then - echo "Existing LaunchAgent found. Unloading..." - launchctl unload "$PLIST_PATH" 2>/dev/null || true - fi + # Unload existing service if present + if [ -f "$PLIST_PATH" ]; then + echo "Existing LaunchAgent found. Unloading..." + launchctl unload "$PLIST_PATH" 2>/dev/null || true + fi - # Create the plist file - cat < "$PLIST_PATH" + # Create the plist file + cat < "$PLIST_PATH" @@ -262,23 +271,35 @@ main() { EOF - # Set permissions - chmod 644 "$PLIST_PATH" - touch /tmp/lume_daemon.log /tmp/lume_daemon.error.log - chmod 644 /tmp/lume_daemon.log /tmp/lume_daemon.error.log + # Set permissions + chmod 644 "$PLIST_PATH" + touch /tmp/lume_daemon.log /tmp/lume_daemon.error.log + chmod 644 /tmp/lume_daemon.log /tmp/lume_daemon.error.log - # Load the LaunchAgent - echo "Loading LaunchAgent..." - launchctl unload "$PLIST_PATH" 2>/dev/null || true - launchctl load "$PLIST_PATH" + # Load the LaunchAgent + echo "Loading LaunchAgent..." + launchctl unload "$PLIST_PATH" 2>/dev/null || true + launchctl load "$PLIST_PATH" - echo "${GREEN}Lume daemon LaunchAgent installed and loaded. It will start automatically on login!${NORMAL}" - echo "To check status: launchctl list | grep $SERVICE_NAME" - echo "To view logs: tail -f /tmp/lume_daemon.log" - echo "" - echo "To remove the lume daemon service, run:" - echo " launchctl unload \"$PLIST_PATH\"" - echo " rm \"$PLIST_PATH\"" + echo "${GREEN}Lume daemon LaunchAgent installed and loaded. It will start automatically on login!${NORMAL}" + echo "To check status: launchctl list | grep $SERVICE_NAME" + echo "To view logs: tail -f /tmp/lume_daemon.log" + echo "" + echo "To remove the lume daemon service, run:" + echo " launchctl unload \"$PLIST_PATH\"" + echo " rm \"$PLIST_PATH\"" + else + SERVICE_NAME="com.trycua.lume_daemon" + PLIST_PATH="$HOME/Library/LaunchAgents/$SERVICE_NAME.plist" + if [ -f "$PLIST_PATH" ]; then + echo "Removing existing Lume background service (LaunchAgent)..." + launchctl unload "$PLIST_PATH" 2>/dev/null || true + rm "$PLIST_PATH" + echo "Lume background service (LaunchAgent) removed." + else + echo "Skipping Lume background service (LaunchAgent) setup as requested (use --no-background-service)." + fi + fi } # Run the installation