Compare commits

...

8 Commits

Author SHA1 Message Date
36ac18c998 Update README with known issue about remote config
- Adjust changelog to be more accurate about remote configuration
- Add 'Known Issues' section to README.md
- Document issue with remote settings not being applied in update mode
- Provide workaround by suggesting manual configuration via web interface
2025-03-05 10:03:25 +00:00
626b24d35e Bump version to 2.0.6 and update changelog
- Update version in package.json to 2.0.6
- Add changelog entries for the latest fixes:
  - Remote configuration settings properly collected and applied
  - Remote host and credentials now correctly stored in config
  - Non-interactive mode support for scripted installations
  - Better handling of piped input for remote configuration
  - Added debug output to help troubleshoot configuration issues
2025-03-05 10:02:42 +00:00
a5afa1bb80 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.
2025-03-05 10:02:23 +00:00
40878c7d3a Fix non-interactive mode for remote Transmission configuration
- Save all piped input to a temporary file for sequential processing
- Read remote mode selection from first line of input
- Use remaining lines for remote Transmission configuration details
- Add proper handling of defaults for empty or missing values
- Improve debug output for configuration parameters

This allows users to pipe all configuration values to the installer in a single command, without requiring interactive prompt responses.
2025-03-05 10:01:27 +00:00
588ba1ea01 Collect Transmission remote details in install-script.sh
- Move Transmission remote details collection to install-script.sh
- Pass all remote details to main-installer.sh via environment file
- Avoid duplicate prompting for remote details
- Improve non-interactive mode with proper default values
- Add check in main-installer.sh to use provided remote details

This solves the problem where remote Transmission details were collected in install-script.sh but not properly used in the main installer when updating an existing installation.
2025-03-05 10:00:25 +00:00
a3924912f1 Improve handling of non-interactive and piped input
- Add detection for non-interactive terminal (piped input)
- Properly read input from pipe in install-script.sh
- Use pre-set environment variables when available
- Add better fallbacks for script usage
- Fix syntax error in main installer script
- More detailed logging of input handling process

This ensures the installer can be used both interactively and in scripts/automated setups.
2025-03-05 09:59:41 +00:00
4e4fd09811 Fix input handling for remote Transmission selection
- Add debug logging to track input values
- Replace regex matching with direct string comparison for better reliability
- Add explicit checks for 'y' and 'Y' input values
- This fixes an issue where remote mode wasn't correctly detected from user input
2025-03-05 09:58:50 +00:00
8af47ed35c 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.
2025-03-05 09:57:30 +00:00
4 changed files with 295 additions and 18 deletions

View File

@ -1,9 +1,16 @@
# Transmission RSS Manager v2.0.5
# Transmission RSS Manager v2.0.6
A comprehensive web-based tool to automate and manage your Transmission torrent downloads with RSS feed integration, intelligent media organization, and enhanced security features. Now with automatic updates and easy installation!
## Changelog
### v2.0.6 (2025-03-05)
- **Added**: Non-interactive mode support for scripted installations
- **Improved**: Remote Transmission configuration collection in install-script.sh
- **Improved**: Better handling of piped input for remote configuration details
- **Improved**: Added debug output to help troubleshoot configuration issues
- **Note**: When updating an existing installation, manual configuration of remote settings through the web interface may still be required
### v2.0.5 (2025-03-05)
- **Fixed**: Config file now properly stored in /etc/transmission-rss-manager directory
- **Fixed**: Remote Transmission detection in install-script.sh
@ -69,6 +76,11 @@ A comprehensive web-based tool to automate and manage your Transmission torrent
## Installation
### Known Issues
- When updating an existing installation with Remote Transmission settings, you may need to manually configure the remote settings through the web interface after installation.
- The installer will properly detect and collect remote Transmission settings, but they may not be applied to the configuration file in update mode.
### Prerequisites
- Ubuntu/Debian-based system (may work on other Linux distributions)

View File

@ -1173,9 +1173,25 @@ 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 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"
# Read the first line as the remote selection
input_remote=$(awk 'NR==1{print}' "$INPUT_FILE")
echo "DEBUG: Non-interactive mode detected, read input: '$input_remote'"
# Keep the rest of the input for later use
tail -n +2 "$INPUT_FILE" > "${INPUT_FILE}.rest"
mv "${INPUT_FILE}.rest" "$INPUT_FILE"
else
read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote
fi
echo "DEBUG: Input received for remote in install-script.sh: '$input_remote'"
# Explicitly check for "y" or "Y" response
if [[ "$input_remote" == "y" ]] || [[ "$input_remote" == "Y" ]]; then
if [ "$input_remote" = "y" ] || [ "$input_remote" = "Y" ]; then
export TRANSMISSION_REMOTE=true
echo -e "${GREEN}Remote Transmission selected.${NC}"
else
@ -1183,8 +1199,84 @@ else
echo -e "${GREEN}Local Transmission selected.${NC}"
fi
# Create a direct environment file for the main installer
echo "export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE" > "${SCRIPT_DIR}/.env.install"
# If remote mode is selected, collect remote details here and pass to main installer
if [ "$TRANSMISSION_REMOTE" = "true" ]; then
# Get remote transmission details
if [ ! -t 0 ]; then
# Non-interactive mode - we already have input saved to INPUT_FILE
# from the previous step
# Read each line from the input file
TRANSMISSION_HOST=$(awk 'NR==1{print}' "$INPUT_FILE")
TRANSMISSION_PORT=$(awk 'NR==2{print}' "$INPUT_FILE")
TRANSMISSION_USER=$(awk 'NR==3{print}' "$INPUT_FILE")
TRANSMISSION_PASS=$(awk 'NR==4{print}' "$INPUT_FILE")
TRANSMISSION_RPC_PATH=$(awk 'NR==5{print}' "$INPUT_FILE")
REMOTE_DOWNLOAD_DIR=$(awk 'NR==6{print}' "$INPUT_FILE")
LOCAL_DOWNLOAD_DIR=$(awk 'NR==7{print}' "$INPUT_FILE")
# Use defaults for empty values
TRANSMISSION_HOST=${TRANSMISSION_HOST:-"localhost"}
TRANSMISSION_PORT=${TRANSMISSION_PORT:-"9091"}
TRANSMISSION_USER=${TRANSMISSION_USER:-""}
TRANSMISSION_PASS=${TRANSMISSION_PASS:-""}
TRANSMISSION_RPC_PATH=${TRANSMISSION_RPC_PATH:-"/transmission/rpc"}
REMOTE_DOWNLOAD_DIR=${REMOTE_DOWNLOAD_DIR:-"/var/lib/transmission-daemon/downloads"}
LOCAL_DOWNLOAD_DIR=${LOCAL_DOWNLOAD_DIR:-"/mnt/transmission-downloads"}
# Clean up
rm -f "$INPUT_FILE"
echo "DEBUG: Non-interactive mode with remote details:"
echo "DEBUG: Host: $TRANSMISSION_HOST, Port: $TRANSMISSION_PORT"
echo "DEBUG: Remote dir: $REMOTE_DOWNLOAD_DIR, Local dir: $LOCAL_DOWNLOAD_DIR"
else
# Interactive mode - ask for details
read -p "Remote Transmission host [localhost]: " TRANSMISSION_HOST
TRANSMISSION_HOST=${TRANSMISSION_HOST:-"localhost"}
read -p "Remote Transmission port [9091]: " TRANSMISSION_PORT
TRANSMISSION_PORT=${TRANSMISSION_PORT:-"9091"}
read -p "Remote Transmission username []: " TRANSMISSION_USER
TRANSMISSION_USER=${TRANSMISSION_USER:-""}
read -s -p "Remote Transmission password []: " TRANSMISSION_PASS
echo # Add a newline after password input
TRANSMISSION_PASS=${TRANSMISSION_PASS:-""}
read -p "Remote Transmission RPC path [/transmission/rpc]: " TRANSMISSION_RPC_PATH
TRANSMISSION_RPC_PATH=${TRANSMISSION_RPC_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
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"}
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"}
fi
# Create the environment file with all remote details
cat > "${SCRIPT_DIR}/.env.install" << EOF
export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE
export TRANSMISSION_HOST="$TRANSMISSION_HOST"
export TRANSMISSION_PORT="$TRANSMISSION_PORT"
export TRANSMISSION_USER="$TRANSMISSION_USER"
export TRANSMISSION_PASS="$TRANSMISSION_PASS"
export TRANSMISSION_RPC_PATH="$TRANSMISSION_RPC_PATH"
export REMOTE_DOWNLOAD_DIR="$REMOTE_DOWNLOAD_DIR"
export LOCAL_DOWNLOAD_DIR="$LOCAL_DOWNLOAD_DIR"
EOF
else
# Local mode - simpler environment file
echo "export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE" > "${SCRIPT_DIR}/.env.install"
fi
chmod +x "${SCRIPT_DIR}/.env.install"
# Ensure the environment file is world-readable to avoid permission issues

View File

@ -105,14 +105,164 @@ 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 check if we already have this value from the environment
# This allows for non-interactive usage in scripts
if [ -n "$TRANSMISSION_REMOTE" ]; then
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
# 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
# If stdin is not a terminal (pipe or redirect), assume default
if [ ! -t 0 ]; then
input_remote="n" # Default to no
log "INFO" "Non-interactive mode detected, using default: local Transmission"
else
read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote
fi
log "INFO" "DEBUG: Input received for remote: '$input_remote'"
fi
# More explicit check for "y" or "Y" input
if [ "$input_remote" = "y" ] || [ "$input_remote" = "Y" ]; 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..."
# 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
if [ -n "$TRANSMISSION_HOST" ] && [ -n "$TRANSMISSION_PORT" ] && [ -n "$REMOTE_DOWNLOAD_DIR" ] && [ -n "$LOCAL_DOWNLOAD_DIR" ]; then
log "INFO" "Using remote Transmission configuration from environment"
# Values are already set from the environment, no need to ask again
else
# 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"}
fi
# Create mapping JSON
TRANSMISSION_DIR_MAPPING=$(cat <<EOF
{
"$REMOTE_DOWNLOAD_DIR": "$LOCAL_DOWNLOAD_DIR"
}
EOF
)
# Create the local directory
mkdir -p "$LOCAL_DOWNLOAD_DIR"
chown -R $USER:$USER "$LOCAL_DOWNLOAD_DIR"
# Update the config file with the new remote settings
log "INFO" "Updating configuration file with remote Transmission settings..."
# Backup the original config file
cp "$CONFIG_DIR/config.json" "$CONFIG_DIR/config.json.bak.$(date +%Y%m%d%H%M%S)"
# Update the isRemote setting
sed -i 's/"isRemote": false/"isRemote": true/' "$CONFIG_DIR/config.json"
# Update the host setting
sed -i "s/\"host\": \"[^\"]*\"/\"host\": \"$TRANSMISSION_HOST\"/" "$CONFIG_DIR/config.json"
# Update the port setting
sed -i "s/\"port\": [0-9]*/\"port\": $TRANSMISSION_PORT/" "$CONFIG_DIR/config.json"
# Update the username setting
sed -i "s/\"username\": \"[^\"]*\"/\"username\": \"$TRANSMISSION_USER\"/" "$CONFIG_DIR/config.json"
# Update the password setting
sed -i "s/\"password\": \"[^\"]*\"/\"password\": \"$TRANSMISSION_PASS\"/" "$CONFIG_DIR/config.json"
# Update the RPC path setting
sed -i "s|\"path\": \"[^\"]*\"|\"path\": \"$TRANSMISSION_RPC_PATH\"|" "$CONFIG_DIR/config.json"
# Update the directory mapping
# Use a more complex approach since it's a JSON object
# This is a simplification and might need improvement for complex JSON handling
sed -i "/\"directoryMapping\":/c\\ \"directoryMapping\": $TRANSMISSION_DIR_MAPPING" "$CONFIG_DIR/config.json"
log "INFO" "Configuration updated for remote Transmission."
fi
else
export TRANSMISSION_REMOTE=false
log "INFO" "Local Transmission selected."
# Update the config file directly to set local mode
if [ -f "$CONFIG_DIR/config.json" ]; then
log "INFO" "Updating configuration file for local Transmission..."
# Backup the original config file
cp "$CONFIG_DIR/config.json" "$CONFIG_DIR/config.json.bak.$(date +%Y%m%d%H%M%S)"
# Update the isRemote setting
sed -i 's/"isRemote": true/"isRemote": false/' "$CONFIG_DIR/config.json"
# Update the host setting
sed -i 's/"host": "[^"]*"/"host": "localhost"/' "$CONFIG_DIR/config.json"
log "INFO" "Configuration updated for local Transmission."
fi
fi
# Step 1: Check dependencies (but don't reconfigure)
log "INFO" "Checking dependencies..."
@ -139,15 +289,38 @@ if [ "$IS_UPDATE" = true ]; then
else
# This is a fresh installation - run all steps
# Step 1: First, let's directly ask about Transmission
# Step 1: First, let's check if we already have this value from the environment
# This allows for non-interactive usage in scripts
if [ -n "$TRANSMISSION_REMOTE" ]; then
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
# 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
# If stdin is not a terminal (pipe or redirect), assume default
if [ ! -t 0 ]; then
input_remote="n" # Default to no
log "INFO" "Non-interactive mode detected, using default: local Transmission"
else
read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote
if [[ $input_remote =~ ^[Yy]$ ]]; then
fi
log "INFO" "DEBUG: Input received for remote: '$input_remote'"
fi
# More explicit check for "y" or "Y" input
if [ "$input_remote" = "y" ] || [ "$input_remote" = "Y" ]; then
export TRANSMISSION_REMOTE=true
log "INFO" "Remote Transmission selected."
else

View File

@ -1,6 +1,6 @@
{
"name": "transmission-rss-manager",
"version": "2.0.5",
"version": "2.0.6",
"description": "A comprehensive web-based tool to automate and manage your Transmission torrent downloads with RSS feed integration and intelligent media organization",
"main": "server.js",
"scripts": {