From cbf1de8a9115b7dcd62928e452b61b7814cee729 Mon Sep 17 00:00:00 2001 From: masterdraco Date: Tue, 25 Feb 2025 13:03:13 +0100 Subject: [PATCH] Update README.md --- README.md | 248 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index 4c855af..25554df 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,100 @@ -Torrent Mover v8.0 -Torrent Mover is a Bash script designed to automate the processing of completed torrents in Transmission. It moves or copies downloaded files from a Transmission‑reported download location to designated destination directories on your system. This enhanced version includes robust locking, advanced error handling, parallel processing, configurable path mapping, and improved archive extraction while ensuring file integrity. - -Features -Automatic Torrent Processing: -Monitors Transmission for completed torrents and processes them based on configurable seeding criteria. - -Configurable Path Mapping: -Uses Transmission’s reported download path (e.g. /downloads) and maps it to your local file system (e.g. /mnt/dsnas2) via configurable settings. - -Robust Locking: -Employs flock to ensure that only one instance of the script runs at a time, preventing conflicts. - -Advanced Error Handling & Logging: -A global error handler traps unexpected errors and logs detailed messages. Logs are output to a specified log file (and optionally to syslog) and support DEBUG mode. - -Parallel File Operations: -Utilizes GNU Parallel for moving, copying, and generating file checksums, making file operations efficient and multi-threaded. - -Archive Extraction with Directory Preservation: -When an archive (RAR, ZIP, 7z) is encountered in the source, it is extracted into a subdirectory (named after the archive, minus its extension) within the destination. Archives remain in the source until Transmission removes them based on seeding ratio/time limits. - -Directory Deduplication: -Prevents re‑processing the same source directory if multiple torrents reference it, ensuring that files aren’t processed repeatedly. - -Optional Integrity Verification: -If enabled, the script re‑calculates and compares file checksums after file transfer to verify integrity. - -Requirements -Bash -Transmission-remote (for interfacing with Transmission) -GNU Parallel -unrar, unzip, 7z (for archive extraction) -bc (for numerical comparisons) -Installation -Download the Script: -Save the script (e.g., torrent-mover.sh) to your desired location (e.g., /usr/local/bin/). - -Make It Executable: - -chmod +x /usr/local/bin/torrent-mover.sh -Create/Edit the Configuration File: -The script expects a configuration file at /etc/torrent/mover.conf. See the Configuration section for details. - -Configuration -Create or modify the configuration file /etc/torrent/mover.conf with variables similar to the following: - + + + + + Torrent Mover v8.0 README + + + +

Torrent Mover v8.0

+ +
+

Description

+

+ Torrent Mover is a Bash script designed to automate the processing of completed torrents in Transmission. + It moves or copies downloaded files from a Transmission‑reported download location to designated destination directories on your system. + This enhanced version includes robust locking, advanced error handling, parallel processing, configurable path mapping, improved archive extraction, + and optional file integrity verification. +

+
+ +
+

Features

+ +
+ +
+

Requirements

+ +
+ +
+

Installation

+
    +
  1. Download the Script: Save the script (e.g., torrent-mover.sh) to your desired location (e.g., /usr/local/bin/).
  2. +
  3. Make It Executable: +
    chmod +x /usr/local/bin/torrent-mover.sh
    +
  4. +
  5. Create/Edit the Configuration File: The script expects a configuration file at /etc/torrent/mover.conf. See the configuration section below.
  6. +
+
+ +
+

Configuration

+

Edit or create /etc/torrent/mover.conf with the following content:

+
 # Transmission settings
 TRANSMISSION_IP="192.168.1.100"         # Replace with your Transmission server's IP
 TRANSMISSION_PORT="9091"                # Replace with your Transmission server's port
@@ -78,51 +128,63 @@ CHECKSUM_DB="/var/lib/torrent/checksums.db"
 
 # Logging settings
 LOG_FILE="/var/log/torrent_mover.log"
-LOG_LEVEL="INFO"  # Change to "DEBUG" for more verbose logging
-USE_SYSLOG="false"  # Set to "true" to log to syslog as well
+LOG_LEVEL="INFO"          # Set to "DEBUG" for more verbose logging
+USE_SYSLOG="false"        # Set to "true" to log messages to syslog
 
-# Optional integrity verification after file transfer ("true" to enable)
+# Optional integrity verification after transfer ("true" to enable)
 CHECK_TRANSFER_INTEGRITY="true"
-Usage
-Run the script with various command-line options:
-
-Dry-run mode (simulate operations):
-
-/usr/local/bin/torrent-mover.sh --dry-run
-Interactive mode (prompt for confirmation):
-
-/usr/local/bin/torrent-mover.sh --interactive
-Cache warmup mode (pre-calculate checksums):
-
-/usr/local/bin/torrent-mover.sh --cache-warmup
-Debug mode (verbose logging):
-
-/usr/local/bin/torrent-mover.sh --debug
-You can combine these options as needed. For example:
-
-/usr/local/bin/torrent-mover.sh --dry-run --debug
-How It Works
-Locking:
-The script uses flock on a lock file to ensure that only one instance runs at a time.
-
-Path Translation:
-The Transmission-reported download path is translated into the actual local path using the mapping provided in the configuration.
-
-Torrent Processing:
-The script uses transmission-remote to list and retrieve torrent information. It processes torrents that are 100% complete (based on percent done) and checks if they’ve already been processed.
-
-File Verification & Deduplication:
-Before copying files, the script compares file checksums between the source and destination. It skips processing if an exact match is found and avoids re‑processing directories already handled for previous torrents.
-
-Archive Extraction:
-Archives in the source are extracted into dedicated subdirectories at the destination. The original archive file is kept until Transmission’s seeding criteria are met (and Transmission subsequently removes the torrent).
-
-Seeding Criteria:
-The script checks seeding ratio and seeding time values. When the criteria are met, it instructs Transmission (via transmission-remote) to remove the torrent.
-
-Integrity Check (Optional):
-If enabled, the script verifies file integrity by comparing md5 checksums of the source and destination files after transfer.
-
-License
-This script is provided as-is. Use at your own risk. Contributions and improvements are welcome!
-
+    
+
+ +
+

Usage

+

Run the script using the following options:

+ +

You can combine options as needed. For example:

+
/usr/local/bin/torrent-mover.sh --dry-run --debug
+
+ +
+

How It Works

+
    +
  1. Locking: Uses flock to ensure only one instance runs at a time.
  2. +
  3. Path Translation: The script translates the Transmission-reported path (e.g., /downloads) to the local file system path (e.g., /mnt/dsnas2) using the configured mapping.
  4. +
  5. Torrent Processing: Retrieves torrent info via transmission-remote and processes torrents that are 100% complete. It skips torrents already processed or those with duplicate source directories.
  6. +
  7. File Verification & Deduplication: Compares file checksums between source and destination, and avoids re‑processing if a match is found.
  8. +
  9. Archive Extraction: Extracts archives (RAR, ZIP, 7z) into subdirectories within the destination while preserving directory structure. The original archive is retained in the source until seeding criteria are met.
  10. +
  11. Seeding Criteria: Checks seeding ratio and time. When thresholds are met, the torrent is removed from Transmission.
  12. +
  13. Integrity Check (Optional): Optionally verifies file integrity by comparing MD5 checksums post-transfer.
  14. +
+
+ +
+

Future Improvements

+ +
+ +
+

License

+

+ This script is provided as-is without any warranty. Use it at your own risk. Contributions and improvements are welcome. +

+
+ +