Update README.md

This commit is contained in:
masterdraco 2025-02-25 13:03:13 +01:00
parent 3287566fb7
commit cbf1de8a91

248
README.md
View File

@ -1,50 +1,100 @@
Torrent Mover v8.0 <!DOCTYPE html>
Torrent Mover is a Bash script designed to automate the processing of completed torrents in Transmission. It moves or copies downloaded files from a Transmissionreported 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. <html lang="en">
<head>
Features <meta charset="UTF-8">
Automatic Torrent Processing: <title>Torrent Mover v8.0 README</title>
Monitors Transmission for completed torrents and processes them based on configurable seeding criteria. <style>
body {
Configurable Path Mapping: font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
Uses Transmissions reported download path (e.g. /downloads) and maps it to your local file system (e.g. /mnt/dsnas2) via configurable settings. margin: 20px;
line-height: 1.6;
Robust Locking: color: #333;
Employs flock to ensure that only one instance of the script runs at a time, preventing conflicts. }
h1, h2, h3 {
Advanced Error Handling & Logging: color: #2C3E50;
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. margin-top: 1em;
}
Parallel File Operations: h1 {
Utilizes GNU Parallel for moving, copying, and generating file checksums, making file operations efficient and multi-threaded. font-size: 2em;
border-bottom: 2px solid #2C3E50;
Archive Extraction with Directory Preservation: padding-bottom: 0.3em;
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. }
pre {
Directory Deduplication: background-color: #F4F4F4;
Prevents reprocessing the same source directory if multiple torrents reference it, ensuring that files arent processed repeatedly. padding: 10px;
border: 1px solid #DDD;
Optional Integrity Verification: border-radius: 4px;
If enabled, the script recalculates and compares file checksums after file transfer to verify integrity. overflow: auto;
}
Requirements code {
Bash background-color: #F4F4F4;
Transmission-remote (for interfacing with Transmission) padding: 2px 4px;
GNU Parallel border-radius: 4px;
unrar, unzip, 7z (for archive extraction) }
bc (for numerical comparisons) .section {
Installation margin-bottom: 20px;
Download the Script: }
Save the script (e.g., torrent-mover.sh) to your desired location (e.g., /usr/local/bin/). ul {
margin-left: 20px;
Make It Executable: }
ol {
chmod +x /usr/local/bin/torrent-mover.sh margin-left: 20px;
Create/Edit the Configuration File: }
The script expects a configuration file at /etc/torrent/mover.conf. See the Configuration section for details. </style>
</head>
Configuration <body>
Create or modify the configuration file /etc/torrent/mover.conf with variables similar to the following: <h1>Torrent Mover v8.0</h1>
<div class="section">
<h2>Description</h2>
<p>
<strong>Torrent Mover</strong> is a Bash script designed to automate the processing of completed torrents in Transmission.
It moves or copies downloaded files from a Transmissionreported 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.
</p>
</div>
<div class="section">
<h2>Features</h2>
<ul>
<li><strong>Automatic Torrent Processing:</strong> Monitors Transmission for completed torrents and processes them based on configurable seeding criteria.</li>
<li><strong>Configurable Path Mapping:</strong> Uses Transmissions reported download path (e.g. <code>/downloads</code>) and maps it to your local file system (e.g. <code>/mnt/dsnas2</code>) via configurable settings.</li>
<li><strong>Robust Locking:</strong> Employs <code>flock</code> to ensure that only one instance of the script runs at a time.</li>
<li><strong>Advanced Error Handling & Logging:</strong> Global error handler and detailed logging (with DEBUG mode support). Optionally, logs to syslog.</li>
<li><strong>Parallel File Operations:</strong> Utilizes GNU Parallel for moving, copying, and generating checksums, enabling efficient multi-threaded processing.</li>
<li><strong>Archive Extraction:</strong> Extracts archives (RAR, ZIP, 7z) into subdirectories at the destination—preserving internal structure—while retaining the archive in the source until seeding criteria are met.</li>
<li><strong>Directory Deduplication:</strong> Prevents reprocessing the same source directory if multiple torrents reference it.</li>
<li><strong>Optional Integrity Verification:</strong> Verifies file integrity by comparing MD5 checksums after transfer.</li>
</ul>
</div>
<div class="section">
<h2>Requirements</h2>
<ul>
<li>Bash</li>
<li>transmission-remote</li>
<li>GNU Parallel</li>
<li>unrar, unzip, 7z</li>
<li>bc</li>
</ul>
</div>
<div class="section">
<h2>Installation</h2>
<ol>
<li><strong>Download the Script:</strong> Save the script (e.g., <code>torrent-mover.sh</code>) to your desired location (e.g., <code>/usr/local/bin/</code>).</li>
<li><strong>Make It Executable:</strong>
<pre>chmod +x /usr/local/bin/torrent-mover.sh</pre>
</li>
<li><strong>Create/Edit the Configuration File:</strong> The script expects a configuration file at <code>/etc/torrent/mover.conf</code>. See the configuration section below.</li>
</ol>
</div>
<div class="section">
<h2>Configuration</h2>
<p>Edit or create <code>/etc/torrent/mover.conf</code> with the following content:</p>
<pre>
# Transmission settings # Transmission settings
TRANSMISSION_IP="192.168.1.100" # Replace with your Transmission server's IP TRANSMISSION_IP="192.168.1.100" # Replace with your Transmission server's IP
TRANSMISSION_PORT="9091" # Replace with your Transmission server's port TRANSMISSION_PORT="9091" # Replace with your Transmission server's port
@ -78,51 +128,63 @@ CHECKSUM_DB="/var/lib/torrent/checksums.db"
# Logging settings # Logging settings
LOG_FILE="/var/log/torrent_mover.log" LOG_FILE="/var/log/torrent_mover.log"
LOG_LEVEL="INFO" # Change to "DEBUG" for more verbose logging LOG_LEVEL="INFO" # Set to "DEBUG" for more verbose logging
USE_SYSLOG="false" # Set to "true" to log to syslog as well 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" CHECK_TRANSFER_INTEGRITY="true"
Usage </pre>
Run the script with various command-line options: </div>
Dry-run mode (simulate operations): <div class="section">
<h2>Usage</h2>
/usr/local/bin/torrent-mover.sh --dry-run <p>Run the script using the following options:</p>
Interactive mode (prompt for confirmation): <ul>
<li><strong>Dry-run mode (simulate operations):</strong>
/usr/local/bin/torrent-mover.sh --interactive <pre>/usr/local/bin/torrent-mover.sh --dry-run</pre>
Cache warmup mode (pre-calculate checksums): </li>
<li><strong>Interactive mode (prompt for confirmation):</strong>
/usr/local/bin/torrent-mover.sh --cache-warmup <pre>/usr/local/bin/torrent-mover.sh --interactive</pre>
Debug mode (verbose logging): </li>
<li><strong>Cache warmup mode (pre-calculate checksums):</strong>
/usr/local/bin/torrent-mover.sh --debug <pre>/usr/local/bin/torrent-mover.sh --cache-warmup</pre>
You can combine these options as needed. For example: </li>
<li><strong>Debug mode (verbose logging):</strong>
/usr/local/bin/torrent-mover.sh --dry-run --debug <pre>/usr/local/bin/torrent-mover.sh --debug</pre>
How It Works </li>
Locking: </ul>
The script uses flock on a lock file to ensure that only one instance runs at a time. <p>You can combine options as needed. For example:</p>
<pre>/usr/local/bin/torrent-mover.sh --dry-run --debug</pre>
Path Translation: </div>
The Transmission-reported download path is translated into the actual local path using the mapping provided in the configuration.
<div class="section">
Torrent Processing: <h2>How It Works</h2>
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 theyve already been processed. <ol>
<li><strong>Locking:</strong> Uses <code>flock</code> to ensure only one instance runs at a time.</li>
File Verification & Deduplication: <li><strong>Path Translation:</strong> The script translates the Transmission-reported path (e.g., <code>/downloads</code>) to the local file system path (e.g., <code>/mnt/dsnas2</code>) using the configured mapping.</li>
Before copying files, the script compares file checksums between the source and destination. It skips processing if an exact match is found and avoids reprocessing directories already handled for previous torrents. <li><strong>Torrent Processing:</strong> Retrieves torrent info via <code>transmission-remote</code> and processes torrents that are 100% complete. It skips torrents already processed or those with duplicate source directories.</li>
<li><strong>File Verification & Deduplication:</strong> Compares file checksums between source and destination, and avoids reprocessing if a match is found.</li>
Archive Extraction: <li><strong>Archive Extraction:</strong> 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.</li>
Archives in the source are extracted into dedicated subdirectories at the destination. The original archive file is kept until Transmissions seeding criteria are met (and Transmission subsequently removes the torrent). <li><strong>Seeding Criteria:</strong> Checks seeding ratio and time. When thresholds are met, the torrent is removed from Transmission.</li>
<li><strong>Integrity Check (Optional):</strong> Optionally verifies file integrity by comparing MD5 checksums post-transfer.</li>
Seeding Criteria: </ol>
The script checks seeding ratio and seeding time values. When the criteria are met, it instructs Transmission (via transmission-remote) to remove the torrent. </div>
Integrity Check (Optional): <div class="section">
If enabled, the script verifies file integrity by comparing md5 checksums of the source and destination files after transfer. <h2>Future Improvements</h2>
<ul>
License <li>Enhanced notifications (e.g., email alerts on errors).</li>
This script is provided as-is. Use at your own risk. Contributions and improvements are welcome! <li>Integration with Transmissions RPC API for more robust data handling.</li>
<li>Structured configuration formats (e.g., JSON or YAML).</li>
<li>Unit testing with frameworks like shunit2.</li>
</ul>
</div>
<div class="section">
<h2>License</h2>
<p>
This script is provided as-is without any warranty. Use it at your own risk. Contributions and improvements are welcome.
</p>
</div>
</body>
</html>