Readme updated
This commit is contained in:
parent
7464b41b18
commit
22abd7fbaf
152
README.md
152
README.md
@ -1,64 +1,128 @@
|
||||
# Torrent Mover
|
||||
Torrent Mover v7.2
|
||||
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.
|
||||
|
||||
A automated torrent management system for handling completed downloads and seeding management.
|
||||
Features
|
||||
Automatic Torrent Processing:
|
||||
Monitors Transmission for completed torrents and processes them based on configurable seeding criteria.
|
||||
|
||||
## Features
|
||||
- Automatic file organization by category (Movies, Games, Apps, Books)
|
||||
- Seeding management based on ratio/time
|
||||
- Archive extraction support (RAR, ZIP, 7z)
|
||||
- Parallel processing
|
||||
- Checksum verification
|
||||
- Storage capacity monitoring
|
||||
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.
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
sudo ./install.sh
|
||||
Robust Locking:
|
||||
Employs flock to ensure that only one instance of the script runs at a time, preventing conflicts.
|
||||
|
||||
Add a cron job to run it every 5 minutes:
|
||||
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.
|
||||
|
||||
sudo crontab -e
|
||||
Add this line:
|
||||
Parallel File Operations:
|
||||
Utilizes GNU Parallel for moving, copying, and generating file checksums, making file operations efficient and multi-threaded.
|
||||
|
||||
*/5 * * * * /usr/local/bin/torrent-mover >/dev/null 2>&1
|
||||
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.
|
||||
|
||||
torrent-mover [options]
|
||||
Options:
|
||||
--dry-run Simulate operations
|
||||
--interactive Confirm before processing
|
||||
--cache-warmup Pre-generate checksums
|
||||
Directory Deduplication:
|
||||
Prevents re‑processing the same source directory if multiple torrents reference it, ensuring that files aren’t processed repeatedly.
|
||||
|
||||
Before first run please check /etc/torrent/mover.conf
|
||||
and correct any needed values there.
|
||||
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/).
|
||||
|
||||
First run:
|
||||
torrent-mover --cache-warmup
|
||||
Make It Executable:
|
||||
|
||||
takes a loooong time since script is generating hash values for all files
|
||||
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:
|
||||
|
||||
# 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
|
||||
TRANSMISSION_USER="your_username" # Transmission username (if set)
|
||||
TRANSMISSION_PASSWORD="your_password" # Transmission password (if set)
|
||||
|
||||
# Path mapping settings
|
||||
TRANSMISSION_PATH_PREFIX="/downloads"
|
||||
LOCAL_PATH_PREFIX="/mnt/dsnas2"
|
||||
|
||||
Git Hosting
|
||||
Repository URL: http://192.168.0.236:3000/masterdraco/torrent
|
||||
# Destination directories
|
||||
DIR_GAMES_DST="/mnt/dsnas1/Games"
|
||||
DIR_APPS_DST="/mnt/dsnas1/Apps"
|
||||
DIR_MOVIES_DST="/mnt/dsnas1/Movies"
|
||||
DIR_BOOKS_DST="/mnt/dsnas1/Books"
|
||||
DEFAULT_DST="/mnt/dsnas1/Other"
|
||||
|
||||
Security
|
||||
Configuration files stored in /etc/torrent
|
||||
# Additional storage directories (comma-separated list)
|
||||
STORAGE_DIRS="/mnt/dsnas/Movies"
|
||||
|
||||
Processed logs in /var/log/torrent_*
|
||||
# Performance settings
|
||||
PARALLEL_THREADS="32"
|
||||
PARALLEL_PROCESSING=1
|
||||
|
||||
Copy
|
||||
# Operation mode: "move" or "copy"
|
||||
COPY_MODE="copy"
|
||||
|
||||
3. **Repository Structure**:
|
||||
```bash
|
||||
.
|
||||
├── etc
|
||||
│ └── torrent
|
||||
│ └── mover.conf
|
||||
├── usr
|
||||
│ └── local
|
||||
│ └── bin
|
||||
│ └── torrent-mover
|
||||
├── install.sh
|
||||
└── README.md
|
||||
# File tracking & integrity
|
||||
PROCESSED_LOG="/var/log/torrent_processed.log"
|
||||
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
|
||||
|
||||
# Optional integrity verification after file 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!
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user