From 8af47ed35c30bcd3343437397fbb76c00d157395 Mon Sep 17 00:00:00 2001 From: MasterDraco Date: Wed, 5 Mar 2025 09:57:30 +0000 Subject: [PATCH] Fix remote transmission configuration in update mode This commit addresses an issue where the remote Transmission settings weren't properly applied when running in update mode: 1. Add prompt for remote Transmission details in update mode 2. Add code to modify the config.json file directly with the user's remote Transmission settings 3. Set default CONFIG_DIR and USER variables early in the script 4. Add detailed configuration dialog including: - Remote host and port - Username and password - RPC path - Directory mapping between remote and local paths This ensures that users selecting remote Transmission mode will always be prompted for the connection details, even when updating an existing installation. --- main-installer.sh | 118 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 3 deletions(-) diff --git a/main-installer.sh b/main-installer.sh index 7b2f9e9..b75d9fe 100755 --- a/main-installer.sh +++ b/main-installer.sh @@ -105,14 +105,126 @@ trap 'cleanup_on_error "$BASH_COMMAND"' ERR # Execute the installation steps in sequence log "INFO" "Starting installation process..." -# Set default for TRANSMISSION_REMOTE +# Set defaults for key variables export TRANSMISSION_REMOTE=false +export CONFIG_DIR=${CONFIG_DIR:-"/etc/transmission-rss-manager"} +export USER=${USER:-$(logname || echo $SUDO_USER)} if [ "$IS_UPDATE" = true ]; then log "INFO" "Running in update mode - preserving existing configuration..." - # When updating, we only need to update core files and dependencies - # Configuration should be preserved + # First, let's directly ask about Transmission + # This is a direct approach that bypasses any potential sourcing issues + log "INFO" "Configuring Transmission connection..." + echo -e "${BOLD}Transmission Configuration:${NC}" + echo -e "Configure connection to your Transmission client:" + echo + + read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote + if [[ $input_remote =~ ^[Yy]$ ]]; then + export TRANSMISSION_REMOTE=true + log "INFO" "Remote Transmission selected." + + # Update the config file directly to set remote mode + if [ -f "$CONFIG_DIR/config.json" ]; then + log "INFO" "Updating configuration file for remote Transmission..." + # Get and validate hostname + read -p "Remote Transmission host [localhost]: " input_trans_host + TRANSMISSION_HOST=${input_trans_host:-"localhost"} + + # Get and validate port + read -p "Remote Transmission port [9091]: " input_trans_port + TRANSMISSION_PORT=${input_trans_port:-9091} + + # Get credentials + read -p "Remote Transmission username []: " input_trans_user + TRANSMISSION_USER=${input_trans_user:-""} + + # Use read -s for password to avoid showing it on screen + read -s -p "Remote Transmission password []: " input_trans_pass + echo # Add a newline after the password input + TRANSMISSION_PASS=${input_trans_pass:-""} + + read -p "Remote Transmission RPC path [/transmission/rpc]: " input_trans_path + TRANSMISSION_RPC_PATH=${input_trans_path:-"/transmission/rpc"} + + # Configure directory mapping for remote setup + echo + echo -e "${YELLOW}Directory Mapping Configuration${NC}" + echo -e "When using a remote Transmission server, you need to map paths between servers." + echo -e "For each directory on the remote server, specify the corresponding local directory." + echo + + # Get remote download directory + read -p "Remote Transmission download directory [/var/lib/transmission-daemon/downloads]: " REMOTE_DOWNLOAD_DIR + REMOTE_DOWNLOAD_DIR=${REMOTE_DOWNLOAD_DIR:-"/var/lib/transmission-daemon/downloads"} + + # Get local directory that corresponds to remote download directory + read -p "Local directory that corresponds to the remote download directory [/mnt/transmission-downloads]: " LOCAL_DOWNLOAD_DIR + LOCAL_DOWNLOAD_DIR=${LOCAL_DOWNLOAD_DIR:-"/mnt/transmission-downloads"} + + # Create mapping JSON + TRANSMISSION_DIR_MAPPING=$(cat <