Compare commits

..

No commits in common. "3287566fb753e70d1ac68362e535948ee5c9abf6" and "7464b41b1883d51d153963cffe4ce8b78c7ce114" have entirely different histories.

152
README.md
View File

@ -1,128 +1,64 @@
Torrent Mover v8.0 # Torrent Mover
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.
Features A automated torrent management system for handling completed downloads and seeding management.
Automatic Torrent Processing:
Monitors Transmission for completed torrents and processes them based on configurable seeding criteria.
Configurable Path Mapping: ## Features
Uses Transmissions reported download path (e.g. /downloads) and maps it to your local file system (e.g. /mnt/dsnas2) via configurable settings. - 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
Robust Locking: ## Installation
Employs flock to ensure that only one instance of the script runs at a time, preventing conflicts. ```bash
sudo ./install.sh
Advanced Error Handling & Logging: Add a cron job to run it every 5 minutes:
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: sudo crontab -e
Utilizes GNU Parallel for moving, copying, and generating file checksums, making file operations efficient and multi-threaded. Add this line:
Archive Extraction with Directory Preservation: */5 * * * * /usr/local/bin/torrent-mover >/dev/null 2>&1
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: torrent-mover [options]
Prevents reprocessing the same source directory if multiple torrents reference it, ensuring that files arent processed repeatedly. Options:
--dry-run Simulate operations
--interactive Confirm before processing
--cache-warmup Pre-generate checksums
Optional Integrity Verification: Before first run please check /etc/torrent/mover.conf
If enabled, the script recalculates and compares file checksums after file transfer to verify integrity. and correct any needed values there.
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: First run:
torrent-mover --cache-warmup
chmod +x /usr/local/bin/torrent-mover.sh takes a loooong time since script is generating hash values for all files
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"
# Destination directories Git Hosting
DIR_GAMES_DST="/mnt/dsnas1/Games" Repository URL: http://192.168.0.236:3000/masterdraco/torrent
DIR_APPS_DST="/mnt/dsnas1/Apps"
DIR_MOVIES_DST="/mnt/dsnas1/Movies"
DIR_BOOKS_DST="/mnt/dsnas1/Books"
DEFAULT_DST="/mnt/dsnas1/Other"
# Additional storage directories (comma-separated list) Security
STORAGE_DIRS="/mnt/dsnas/Movies" Configuration files stored in /etc/torrent
# Performance settings Processed logs in /var/log/torrent_*
PARALLEL_THREADS="32"
PARALLEL_PROCESSING=1
# Operation mode: "move" or "copy" Copy
COPY_MODE="copy"
# File tracking & integrity 3. **Repository Structure**:
PROCESSED_LOG="/var/log/torrent_processed.log" ```bash
CHECKSUM_DB="/var/lib/torrent/checksums.db" .
├── etc
# Logging settings │ └── torrent
LOG_FILE="/var/log/torrent_mover.log" │ └── mover.conf
LOG_LEVEL="INFO" # Change to "DEBUG" for more verbose logging ├── usr
USE_SYSLOG="false" # Set to "true" to log to syslog as well │ └── local
│ └── bin
# Optional integrity verification after file transfer ("true" to enable) │ └── torrent-mover
CHECK_TRANSFER_INTEGRITY="true" ├── install.sh
Usage └── README.md
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 theyve 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 reprocessing 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 Transmissions 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!