Fix configuration detection in update mode

- 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 <noreply@anthropic.com>
This commit is contained in:
MasterDraco 2025-03-10 17:01:51 +00:00
parent 2dcd4becef
commit eaed045323

View File

@ -1197,14 +1197,37 @@ fi
# Launch the main installer # Launch the main installer
echo -e "${GREEN}Launching main installer...${NC}" echo -e "${GREEN}Launching main installer...${NC}"
# Ask about remote Transmission before launching main installer # Skip Transmission configuration if we're in update mode
# This ensures the TRANSMISSION_REMOTE variable is set correctly if [ "$IS_UPDATE" = "true" ] && [ -n "$EXISTING_CONFIG_PATH" ]; then
echo -e "${BOLD}Transmission Configuration:${NC}" echo -e "${GREEN}Existing configuration detected, skipping Transmission configuration...${NC}"
echo -e "Configure connection to your Transmission client:"
echo
# If stdin is not a terminal (pipe or redirect), read from stdin # Extract Transmission remote setting from existing config
if [ ! -t 0 ]; then 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
# Save all input to a temporary file # Save all input to a temporary file
INPUT_FILE=$(mktemp) INPUT_FILE=$(mktemp)
cat > "$INPUT_FILE" cat > "$INPUT_FILE"
@ -1227,10 +1250,11 @@ if [ "$input_remote" = "y" ] || [ "$input_remote" = "Y" ]; then
else else
export TRANSMISSION_REMOTE=false export TRANSMISSION_REMOTE=false
echo -e "${GREEN}Local Transmission selected.${NC}" echo -e "${GREEN}Local Transmission selected.${NC}"
fi
fi fi
# If remote mode is selected, collect remote details here and pass to main installer # If remote mode is selected and not an update, collect remote details here and pass to main installer
if [ "$TRANSMISSION_REMOTE" = "true" ]; then if [ "$TRANSMISSION_REMOTE" = "true" ] && [ "$IS_UPDATE" != "true" ]; then
# Get remote transmission details # Get remote transmission details
if [ ! -t 0 ]; then if [ ! -t 0 ]; then
# Non-interactive mode - we already have input saved to INPUT_FILE # 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 # Ensure the environment file is world-readable to avoid permission issues
chmod 644 "${SCRIPT_DIR}/.env.install" 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 # 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 if ! grep -q "source.*\.env\.install" "${SCRIPT_DIR}/main-installer.sh"; then
# Backup the main installer # Backup the main installer