From eaed045323dabdcea54f48b03dcbc2e45bfef773 Mon Sep 17 00:00:00 2001 From: MasterDraco Date: Mon, 10 Mar 2025 17:01:51 +0000 Subject: [PATCH] Fix configuration detection in update mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Skip Transmission configuration prompt when updating an existing installation - Automatically detect remote/local setting from existing config - Properly export update-related variables to environment file - Fix indentation issues in conditional statements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- install-script.sh | 53 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/install-script.sh b/install-script.sh index e689adb..b6e3c9b 100755 --- a/install-script.sh +++ b/install-script.sh @@ -1197,14 +1197,37 @@ fi # Launch the main installer echo -e "${GREEN}Launching main installer...${NC}" -# Ask about remote Transmission before launching main installer -# This ensures the TRANSMISSION_REMOTE variable is set correctly -echo -e "${BOLD}Transmission Configuration:${NC}" -echo -e "Configure connection to your Transmission client:" -echo +# Skip Transmission configuration if we're in update mode +if [ "$IS_UPDATE" = "true" ] && [ -n "$EXISTING_CONFIG_PATH" ]; then + echo -e "${GREEN}Existing configuration detected, skipping Transmission configuration...${NC}" + + # Extract Transmission remote setting from existing config + if [ -f "$EXISTING_CONFIG_PATH" ]; then + # Try to extract remoteConfig.isRemote value from config.json + if command -v grep &> /dev/null && command -v sed &> /dev/null; then + IS_REMOTE=$(grep -o '"isRemote":[^,}]*' "$EXISTING_CONFIG_PATH" | sed 's/"isRemote"://; s/[[:space:]]//g') + if [ "$IS_REMOTE" = "true" ]; then + export TRANSMISSION_REMOTE=true + echo -e "${GREEN}Using existing remote Transmission configuration.${NC}" + else + export TRANSMISSION_REMOTE=false + echo -e "${GREEN}Using existing local Transmission configuration.${NC}" + fi + else + # Default to false if we can't extract it + export TRANSMISSION_REMOTE=false + echo -e "${YELLOW}Could not determine Transmission remote setting, using local configuration.${NC}" + fi + fi +else + # Ask about remote Transmission before launching main installer + # This ensures the TRANSMISSION_REMOTE variable is set correctly + echo -e "${BOLD}Transmission Configuration:${NC}" + echo -e "Configure connection to your Transmission client:" + echo -# If stdin is not a terminal (pipe or redirect), read from stdin -if [ ! -t 0 ]; then + # If stdin is not a terminal (pipe or redirect), read from stdin + if [ ! -t 0 ]; then # Save all input to a temporary file INPUT_FILE=$(mktemp) cat > "$INPUT_FILE" @@ -1225,12 +1248,13 @@ if [ "$input_remote" = "y" ] || [ "$input_remote" = "Y" ]; then export TRANSMISSION_REMOTE=true echo -e "${GREEN}Remote Transmission selected.${NC}" else - export TRANSMISSION_REMOTE=false - echo -e "${GREEN}Local Transmission selected.${NC}" + export TRANSMISSION_REMOTE=false + echo -e "${GREEN}Local Transmission selected.${NC}" + fi fi -# If remote mode is selected, collect remote details here and pass to main installer -if [ "$TRANSMISSION_REMOTE" = "true" ]; then +# If remote mode is selected and not an update, collect remote details here and pass to main installer +if [ "$TRANSMISSION_REMOTE" = "true" ] && [ "$IS_UPDATE" != "true" ]; then # Get remote transmission details if [ ! -t 0 ]; then # Non-interactive mode - we already have input saved to INPUT_FILE @@ -1312,6 +1336,13 @@ chmod +x "${SCRIPT_DIR}/.env.install" # Ensure the environment file is world-readable to avoid permission issues chmod 644 "${SCRIPT_DIR}/.env.install" +# If we're in update mode, add the existing installation path to the environment file +if [ "$IS_UPDATE" = "true" ] && [ -n "$EXISTING_CONFIG_PATH" ]; then + echo "export EXISTING_CONFIG_PATH=\"$EXISTING_CONFIG_PATH\"" >> "${SCRIPT_DIR}/.env.install" + echo "export EXISTING_INSTALL_DIR=\"$EXISTING_INSTALL_DIR\"" >> "${SCRIPT_DIR}/.env.install" + echo "export IS_UPDATE=true" >> "${SCRIPT_DIR}/.env.install" +fi + # Force inclusion in the main installer - modify the main installer temporarily if needed if ! grep -q "source.*\.env\.install" "${SCRIPT_DIR}/main-installer.sh"; then # Backup the main installer