From 4c68a1ac07d4a9c20513e4223786d0e1046df5bf Mon Sep 17 00:00:00 2001 From: MasterDraco Date: Wed, 5 Mar 2025 08:39:21 +0000 Subject: [PATCH] Fix remote Transmission detection and config directory creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix bug where installer doesn't ask if Transmission is remote - Fix missing configuration directory in /etc/transmission-rss-manager - Create symlink between config locations to ensure app always finds config - Ensure CONFIG_DIR is properly exported in the environment - Update version to 2.0.4 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- README.md | 7 ++- main-installer.sh | 2 + modules/config-module.sh | 4 ++ modules/dependencies-module.sh | 12 ++-- modules/file-creator-module.sh | 1 + package.json | 2 +- temp_work/SUMMARY.md | 103 ++++++++++++--------------------- 7 files changed, 60 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 2f4fbbf..0cd2968 100755 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ -# Transmission RSS Manager v2.0.3 +# Transmission RSS Manager v2.0.4 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.4 (2025-03-05) +- **Fixed**: Remote transmission detection in installer +- **Fixed**: Configuration directory creation and permissions +- **Fixed**: Config file symlink now ensures application finds correct config location + ### v2.0.3 (2025-03-05) - **New**: Configuration file now stored in `/etc/transmission-rss-manager/` - **Improved**: Installer creates config directory with proper permissions diff --git a/main-installer.sh b/main-installer.sh index c11d89b..58188d2 100755 --- a/main-installer.sh +++ b/main-installer.sh @@ -146,6 +146,8 @@ else # Step 3: Create installation directories log "INFO" "Creating directories..." + # Make sure CONFIG_DIR is set and exported + export CONFIG_DIR=${CONFIG_DIR:-"/etc/transmission-rss-manager"} create_directories || { log "ERROR" "Directory creation failed" exit 1 diff --git a/modules/config-module.sh b/modules/config-module.sh index 546de62..b14dfb5 100644 --- a/modules/config-module.sh +++ b/modules/config-module.sh @@ -114,6 +114,7 @@ function gather_configuration() { read -p "Is Transmission running on a remote server? (y/n) [n]: " input_remote if [[ $input_remote =~ ^[Yy]$ ]]; then TRANSMISSION_REMOTE=true + export TRANSMISSION_REMOTE=true # Get and validate hostname while true; do @@ -227,6 +228,9 @@ function gather_configuration() { TRANSMISSION_DOWNLOAD_DIR=$REMOTE_DOWNLOAD_DIR else # Local Transmission selected + TRANSMISSION_REMOTE=false + export TRANSMISSION_REMOTE=false + echo -e "${YELLOW}You've selected to use a local Transmission installation.${NC}" # Check if Transmission is already installed diff --git a/modules/dependencies-module.sh b/modules/dependencies-module.sh index a588b09..f8828a8 100644 --- a/modules/dependencies-module.sh +++ b/modules/dependencies-module.sh @@ -35,8 +35,8 @@ function install_dependencies() { log "INFO" "Node.js is already installed." fi - # Check if we need to install Transmission (only if local transmission was selected and not remote) - if [ "$TRANSMISSION_REMOTE" = false ] && ([ "$TRANSMISSION_HOST" = "localhost" ] || [ "$TRANSMISSION_HOST" = "127.0.0.1" ]); then + # Check if we need to install Transmission (only if local transmission was selected) + if [ "$TRANSMISSION_REMOTE" = false ]; then if ! command_exists transmission-daemon; then log "INFO" "Local Transmission installation selected, but transmission-daemon is not installed." read -p "Would you like to install Transmission now? (y/n): " install_transmission @@ -109,8 +109,8 @@ function install_dependencies() { local dependencies=("node" "npm" "unzip" "nginx") local missing_deps=() - # Add transmission to dependencies check if local installation was selected and not remote - if [ "$TRANSMISSION_REMOTE" = false ] && ([ "$TRANSMISSION_HOST" = "localhost" ] || [ "$TRANSMISSION_HOST" = "127.0.0.1" ]); then + # Add transmission to dependencies check if local installation was selected + if [ "$TRANSMISSION_REMOTE" = false ]; then dependencies+=("transmission-daemon") fi @@ -191,5 +191,9 @@ function create_directories() { chown -R "$USER:$USER" "$CONFIG_DIR" chmod 755 "$CONFIG_DIR" + # Create a symlink from the installation directory to the config directory + # This ensures the application can find the config regardless of where it looks + ln -sf "$CONFIG_DIR/config.json" "$INSTALL_DIR/config.json" + log "INFO" "Directories created successfully." } \ No newline at end of file diff --git a/modules/file-creator-module.sh b/modules/file-creator-module.sh index 0edd7e8..92f60e5 100644 --- a/modules/file-creator-module.sh +++ b/modules/file-creator-module.sh @@ -6,6 +6,7 @@ function create_config_files() { # Create initial config.json echo "Creating config.json..." + mkdir -p "$CONFIG_DIR" cat > $CONFIG_DIR/config.json << EOF { "version": "2.0.3", diff --git a/package.json b/package.json index a806596..6ad9795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "transmission-rss-manager", - "version": "2.0.3", + "version": "2.0.4", "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": { diff --git a/temp_work/SUMMARY.md b/temp_work/SUMMARY.md index b52e62f..cb0b1d3 100644 --- a/temp_work/SUMMARY.md +++ b/temp_work/SUMMARY.md @@ -1,75 +1,48 @@ -# Git-Based Installation and Update System +# Changes for Moving Config File to /etc/transmission-rss-manager -We've restructured the Transmission RSS Manager to use a git-based approach for installation and updates. Here's how the new system works: +## Overview +This update moves the configuration file from the application directory to `/etc/transmission-rss-manager/config.json` for better system organization, while maintaining backward compatibility by checking the original location as a fallback. -## New Architecture +## Changes Made -1. **Bootstrap Installer** - - Small, self-contained installer script - - Installs git if needed - - Clones the main repository - - Runs the main installer +### 1. Server.js Updates +- Changed default config location to `/etc/transmission-rss-manager/config.json` +- Added fallback location (`path.join(__dirname, 'config.json')`) for backward compatibility +- Enhanced `loadConfig()` function to try primary location first, then fallback location +- Updated `saveConfig()` function to try saving to primary location first, then fallback +- Added `installPath` property to configuration to store the application installation path for easier updates -2. **Main Installer** - - Modified to work with git-managed files - - Doesn't need to generate application files - - Only creates config files and sets up services +### 2. Installer Updates +- Added `CONFIG_DIR="/etc/transmission-rss-manager"` variable to config-module.sh +- Updated `create_directories()` in dependencies-module.sh to create the config directory +- Updated permission settings to ensure proper access to config directory +- Added checks for the CONFIG_DIR variable to ensure it's set +- Modified service-setup-module.sh to include CONFIG_DIR in the environment variables for the systemd service +- Updated file-creator-module.sh to write the initial config.json to the new location -3. **Update System** - - Web interface shows current version - - Checks for updates automatically - - One-click update process - - Preserves user configuration +### 3. Documentation Updates +- Updated README.md to reflect new config file location +- Added entry to the changelog for version 2.0.3 +- Updated code examples in README +- Bumped version from 2.0.2 to 2.0.3 in both README.md and package.json -## Key Files +## Technical Details -1. **bootstrap-installer.sh** - - Entry point for new installations - - Minimal script that pulls everything else from git +### Config File Loading Process +1. Try to load config from primary location (`/etc/transmission-rss-manager/config.json`) +2. If not found, try fallback location (`/config.json`) +3. If neither exists, create a new config file at primary location +4. If primary location is not writable, fall back to application directory -2. **update.sh** - - Located in the scripts/ directory - - Handles git pull and service restart - - Preserves local configuration changes - -3. **System Status UI** - - Added to the dashboard - - Shows version, uptime, and connection status - - Notifies when updates are available - -4. **Server Endpoints** - - `/api/system/status` - Gets current version and system status - - `/api/system/check-updates` - Checks if updates are available - - `/api/system/update` - Triggers the update process +### Configuration Storage Logic +- Primary storage location: `/etc/transmission-rss-manager/config.json` +- Fallback location: `/config.json` +- Automatic migration from fallback to primary when possible +- Always try to write to primary first, then fallback if needed ## Benefits - -1. **Simplified Maintenance** - - Single source of truth in the git repository - - No need to embed code in installation scripts - - Easy to make changes and publish updates - -2. **Better User Experience** - - Users can see when updates are available - - One-click update process - - No need to manually download and run scripts - -3. **Version Control** - - Clear versioning visible to users - - Update history preserved in git - - Easy rollback if needed - -## Implementation Notes - -This implementation preserves local configuration by: -1. Stashing local changes before pulling updates -2. Applying those changes back after the update -3. Handling any potential conflicts - -The service automatically restarts after updates, ensuring users always have the latest version running. - -## Next Steps - -1. Update the GitHub repository structure to match this new approach -2. Test the installation and update process in a clean environment -3. Consider adding a changelog display in the UI to show what's new in each version \ No newline at end of file +- More standard Linux configuration location in /etc +- Easier to find and edit configuration +- Clear separation between code and configuration +- Maintains backward compatibility with existing installations +- Simplified update process by storing installation path