Improve environment variable handling in main installer

- Add logic to set input_remote based on TRANSMISSION_REMOTE from environment
- Add detailed debug logging for environment variables
- Ensure consistent behavior between direct mode and piped input
- Fix issue where environment variables weren't correctly propagating

This ensures that when remote mode is selected in install-script.sh, it's correctly respected in the main installer even when running in update mode.
This commit is contained in:
MasterDraco 2025-03-05 10:02:23 +00:00
parent 40878c7d3a
commit a5afa1bb80

View File

@ -116,7 +116,16 @@ if [ "$IS_UPDATE" = true ]; then
# First, let's check if we already have this value from the environment # First, let's check if we already have this value from the environment
# This allows for non-interactive usage in scripts # This allows for non-interactive usage in scripts
if [ -n "$TRANSMISSION_REMOTE" ]; then if [ -n "$TRANSMISSION_REMOTE" ]; then
log "INFO" "Using Transmission mode from environment: $([ "$TRANSMISSION_REMOTE" = true ] && echo "Remote" || echo "Local")" is_remote=$([ "$TRANSMISSION_REMOTE" = true ] && echo "Remote" || echo "Local")
log "INFO" "Using Transmission mode from environment: $is_remote"
# Set the input_remote variable based on the environment variable
# This ensures consistent behavior with the rest of the script
if [ "$TRANSMISSION_REMOTE" = true ]; then
input_remote="y"
else
input_remote="n"
fi
else else
# Directly ask about Transmission # Directly ask about Transmission
# This is a direct approach that bypasses any potential sourcing issues # This is a direct approach that bypasses any potential sourcing issues
@ -144,6 +153,13 @@ if [ "$IS_UPDATE" = true ]; then
if [ -f "$CONFIG_DIR/config.json" ]; then if [ -f "$CONFIG_DIR/config.json" ]; then
log "INFO" "Updating configuration file for remote Transmission..." log "INFO" "Updating configuration file for remote Transmission..."
# Log all environment variables we have for debugging
log "INFO" "DEBUG: Environment variables for remote configuration:"
log "INFO" "DEBUG: TRANSMISSION_HOST=${TRANSMISSION_HOST:-'not set'}"
log "INFO" "DEBUG: TRANSMISSION_PORT=${TRANSMISSION_PORT:-'not set'}"
log "INFO" "DEBUG: REMOTE_DOWNLOAD_DIR=${REMOTE_DOWNLOAD_DIR:-'not set'}"
log "INFO" "DEBUG: LOCAL_DOWNLOAD_DIR=${LOCAL_DOWNLOAD_DIR:-'not set'}"
# Check if we already have the remote configuration details from the environment # Check if we already have the remote configuration details from the environment
if [ -n "$TRANSMISSION_HOST" ] && [ -n "$TRANSMISSION_PORT" ] && [ -n "$REMOTE_DOWNLOAD_DIR" ] && [ -n "$LOCAL_DOWNLOAD_DIR" ]; then if [ -n "$TRANSMISSION_HOST" ] && [ -n "$TRANSMISSION_PORT" ] && [ -n "$REMOTE_DOWNLOAD_DIR" ] && [ -n "$LOCAL_DOWNLOAD_DIR" ]; then
log "INFO" "Using remote Transmission configuration from environment" log "INFO" "Using remote Transmission configuration from environment"
@ -276,7 +292,16 @@ else
# Step 1: First, let's check if we already have this value from the environment # Step 1: First, let's check if we already have this value from the environment
# This allows for non-interactive usage in scripts # This allows for non-interactive usage in scripts
if [ -n "$TRANSMISSION_REMOTE" ]; then if [ -n "$TRANSMISSION_REMOTE" ]; then
log "INFO" "Using Transmission mode from environment: $([ "$TRANSMISSION_REMOTE" = true ] && echo "Remote" || echo "Local")" is_remote=$([ "$TRANSMISSION_REMOTE" = true ] && echo "Remote" || echo "Local")
log "INFO" "Using Transmission mode from environment: $is_remote"
# Set the input_remote variable based on the environment variable
# This ensures consistent behavior with the rest of the script
if [ "$TRANSMISSION_REMOTE" = true ]; then
input_remote="y"
else
input_remote="n"
fi
else else
# Directly ask about Transmission # Directly ask about Transmission
# This is a direct approach that bypasses any potential sourcing issues # This is a direct approach that bypasses any potential sourcing issues