Compare commits

..

No commits in common. "36ac18c9986a337ca73fc892d7ac3e94c3045e67" and "1c16243a2d46e5e6b761bc046ac6b6791dcce7f9" have entirely different histories.

4 changed files with 18 additions and 295 deletions

View File

@ -1,16 +1,9 @@
# Transmission RSS Manager v2.0.6 # Transmission RSS Manager v2.0.5
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! 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 ## 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) ### v2.0.5 (2025-03-05)
- **Fixed**: Config file now properly stored in /etc/transmission-rss-manager directory - **Fixed**: Config file now properly stored in /etc/transmission-rss-manager directory
- **Fixed**: Remote Transmission detection in install-script.sh - **Fixed**: Remote Transmission detection in install-script.sh
@ -76,11 +69,6 @@ A comprehensive web-based tool to automate and manage your Transmission torrent
## Installation ## 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 ### Prerequisites
- Ubuntu/Debian-based system (may work on other Linux distributions) - Ubuntu/Debian-based system (may work on other Linux distributions)

View File

@ -1173,25 +1173,9 @@ echo -e "${BOLD}Transmission Configuration:${NC}"
echo -e "Configure connection to your Transmission client:" echo -e "Configure connection to your Transmission client:"
echo echo
# If stdin is not a terminal (pipe or redirect), read from stdin read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote
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 # 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 export TRANSMISSION_REMOTE=true
echo -e "${GREEN}Remote Transmission selected.${NC}" echo -e "${GREEN}Remote Transmission selected.${NC}"
else else
@ -1199,84 +1183,8 @@ else
echo -e "${GREEN}Local Transmission selected.${NC}" echo -e "${GREEN}Local Transmission selected.${NC}"
fi fi
# If remote mode is selected, collect remote details here and pass to main installer # Create a direct environment file for the main installer
if [ "$TRANSMISSION_REMOTE" = "true" ]; then echo "export TRANSMISSION_REMOTE=$TRANSMISSION_REMOTE" > "${SCRIPT_DIR}/.env.install"
# 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" 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

View File

@ -105,164 +105,14 @@ trap 'cleanup_on_error "$BASH_COMMAND"' ERR
# Execute the installation steps in sequence # Execute the installation steps in sequence
log "INFO" "Starting installation process..." log "INFO" "Starting installation process..."
# Set defaults for key variables # Set default for TRANSMISSION_REMOTE
export TRANSMISSION_REMOTE=false 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 if [ "$IS_UPDATE" = true ]; then
log "INFO" "Running in update mode - preserving existing configuration..." log "INFO" "Running in update mode - preserving existing configuration..."
# First, let's check if we already have this value from the environment # When updating, we only need to update core files and dependencies
# This allows for non-interactive usage in scripts # Configuration should be preserved
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) # Step 1: Check dependencies (but don't reconfigure)
log "INFO" "Checking dependencies..." log "INFO" "Checking dependencies..."
@ -289,38 +139,15 @@ EOF
else else
# This is a fresh installation - run all steps # This is a fresh installation - run all steps
# Step 1: First, let's check if we already have this value from the environment # Step 1: First, let's directly ask about Transmission
# This allows for non-interactive usage in scripts # This is a direct approach that bypasses any potential sourcing issues
if [ -n "$TRANSMISSION_REMOTE" ]; then log "INFO" "Configuring Transmission connection..."
is_remote=$([ "$TRANSMISSION_REMOTE" = true ] && echo "Remote" || echo "Local") echo -e "${BOLD}Transmission Configuration:${NC}"
log "INFO" "Using Transmission mode from environment: $is_remote" echo -e "Configure connection to your Transmission client:"
echo
# Set the input_remote variable based on the environment variable
# This ensures consistent behavior with the rest of the script read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote
if [ "$TRANSMISSION_REMOTE" = true ]; then if [[ $input_remote =~ ^[Yy]$ ]]; 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 export TRANSMISSION_REMOTE=true
log "INFO" "Remote Transmission selected." log "INFO" "Remote Transmission selected."
else else

View File

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