Update README.md
This commit is contained in:
parent
3287566fb7
commit
cbf1de8a91
230
README.md
230
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.
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Torrent Mover v8.0 README</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
|
||||
margin: 20px;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
color: #2C3E50;
|
||||
margin-top: 1em;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
border-bottom: 2px solid #2C3E50;
|
||||
padding-bottom: 0.3em;
|
||||
}
|
||||
pre {
|
||||
background-color: #F4F4F4;
|
||||
padding: 10px;
|
||||
border: 1px solid #DDD;
|
||||
border-radius: 4px;
|
||||
overflow: auto;
|
||||
}
|
||||
code {
|
||||
background-color: #F4F4F4;
|
||||
padding: 2px 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
ul {
|
||||
margin-left: 20px;
|
||||
}
|
||||
ol {
|
||||
margin-left: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Torrent Mover v8.0</h1>
|
||||
|
||||
Features
|
||||
Automatic Torrent Processing:
|
||||
Monitors Transmission for completed torrents and processes them based on configurable seeding criteria.
|
||||
<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 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.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
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.
|
||||
<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 Transmission’s 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 re‑processing 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>
|
||||
|
||||
Robust Locking:
|
||||
Employs flock to ensure that only one instance of the script runs at a time, preventing conflicts.
|
||||
<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>
|
||||
|
||||
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:
|
||||
<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_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:
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
Dry-run mode (simulate operations):
|
||||
<div class="section">
|
||||
<h2>Usage</h2>
|
||||
<p>Run the script using the following options:</p>
|
||||
<ul>
|
||||
<li><strong>Dry-run mode (simulate operations):</strong>
|
||||
<pre>/usr/local/bin/torrent-mover.sh --dry-run</pre>
|
||||
</li>
|
||||
<li><strong>Interactive mode (prompt for confirmation):</strong>
|
||||
<pre>/usr/local/bin/torrent-mover.sh --interactive</pre>
|
||||
</li>
|
||||
<li><strong>Cache warmup mode (pre-calculate checksums):</strong>
|
||||
<pre>/usr/local/bin/torrent-mover.sh --cache-warmup</pre>
|
||||
</li>
|
||||
<li><strong>Debug mode (verbose logging):</strong>
|
||||
<pre>/usr/local/bin/torrent-mover.sh --debug</pre>
|
||||
</li>
|
||||
</ul>
|
||||
<p>You can combine options as needed. For example:</p>
|
||||
<pre>/usr/local/bin/torrent-mover.sh --dry-run --debug</pre>
|
||||
</div>
|
||||
|
||||
/usr/local/bin/torrent-mover.sh --dry-run
|
||||
Interactive mode (prompt for confirmation):
|
||||
<div class="section">
|
||||
<h2>How It Works</h2>
|
||||
<ol>
|
||||
<li><strong>Locking:</strong> Uses <code>flock</code> to ensure only one instance runs at a time.</li>
|
||||
<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>
|
||||
<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 re‑processing if a match is found.</li>
|
||||
<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>
|
||||
<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>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
/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!
|
||||
<div class="section">
|
||||
<h2>Future Improvements</h2>
|
||||
<ul>
|
||||
<li>Enhanced notifications (e.g., email alerts on errors).</li>
|
||||
<li>Integration with Transmission’s 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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user