codenamezero
Explorer
- Joined
- Sep 4, 2011
- Messages
- 59
STEP 1
Install Transmission, follow one of the online Transmission guide and note down the following...
We will need those 2 paths later on, but that's how I setup mine.
STEP 2
Decide on a location where you want to put the automated torrent removal scripts. I decided to put it here...
These are the contents of my scripts:
Set environment script
Helper script
Torrent removal script
You can test to see if the script is working or not by manually running ./rm_completed_bt.sh, just make sure your Transmission had a completed torrent sitting there seeding. If it works, you should see something like this on the screen:
STEP 3
Next step is to set it up in cron, if you are running 8.01 Beta, you can probably set it up using the WebGUI, however, I did it in 8.0 and I don't plan on upgrading it so here is how to do it... took me a while to figure it out.
Basically you need to edit /conf/base/var/cron/tab/root
However, the syntax is a little different, you don't need to specify the username...
So, lets go ahead and do mount -uw / so that you can create and edit the file /conf/base/var/cron/tab/root
Put the following in the root file (you will need to manually create the root file)
Reboot, and after it finish rebooting type the following:
You should see the cron job is being loaded in the list.
PS: The log file is optional, you can simply comment it out from the script.
Cheers!
Install Transmission, follow one of the online Transmission guide and note down the following...
Code:
freenas# cat /conf/base/etc/rc.d/transmission #!/bin/sh . /etc/rc.subr name="transmission" rcvar=${name}_enable command=/usr/local/bin/transmission-daemon load_rc_config ${name} : ${transmission_enable:="YES"} : ${transmission_user:="root"} : ${transmission_conf_dir:="/mnt/FREENAS/torrent/conf"} : ${transmission_download_dir:="/mnt/FREENAS/torrent"} transmission_flags=" \ ${transmission_watch_dir:+-c ${transmission_watch_dir}} \ ${transmission_conf_dir:+-g ${transmission_conf_dir}} \ ${transmission_download_dir:+-w ${transmission_download_dir}} \ ${transmission_flags}" run_rc_command "$1"
We will need those 2 paths later on, but that's how I setup mine.
STEP 2
Decide on a location where you want to put the automated torrent removal scripts. I decided to put it here...
Code:
freenas# pwd
/mnt/FREENAS/torrent/bin
freenas# ls -rtl
total 6
-rw-r--r-- 1 root www 27 Sep 3 01:24 set_env
-rwxr-xr-x 1 root www 240 Sep 6 23:08 get_torrents_by_percentage
-rwxr-xr-x 1 root www 171 Sep 6 23:08 get_torrents_by_ratio
-rwxr-xr-x 1 root www 354 Sep 8 01:11 rm_completed_bt.sh
These are the contents of my scripts:
Set environment script
Code:
freenas# cat set_env # Where transmission-remote is located PATH=$PATH:/usr/local/bin # Where the automated scripts are located BINPATH=/mnt/FREENAS/torrent/bin # Username and password for your Transmission username=<Your Transmission login name> password=<Your Transmission password>
Helper script
Code:
freenas# cat get_torrents_by_percentage #!/bin/sh . set_env if [ "$1" != "" ] then transmission-remote -n $username:$password -l | grep $1 | cut -c 1-5 -c 71- else echo "Usage: $0 <0-100>" fi
Torrent removal script
Code:
freenas# cat rm_completed_bt.sh #!/bin/sh . set_env cd $BINPATH torrents=`./get_torrents_by_percentage 100` IFS=" " #echo "Running rm_completed_bt.sh" for torrent in $torrents; do id=`echo $torrent | awk '{ print $1 }'` echo "Removing torrent ID# $torrent" transmission-remote -n $username:$password -t $id -r done
You can test to see if the script is working or not by manually running ./rm_completed_bt.sh, just make sure your Transmission had a completed torrent sitting there seeding. If it works, you should see something like this on the screen:
Code:
freenas# /mnt/FREENAS/torrent/bin/rm_completed_bt.sh Removing torrent ID# 1 [UTW]_Appleseed_XIII_-_02_[BD][h264-720p_FLAC][E8D09710].mkv localhost:9091 responded: "success"
STEP 3
Next step is to set it up in cron, if you are running 8.01 Beta, you can probably set it up using the WebGUI, however, I did it in 8.0 and I don't plan on upgrading it so here is how to do it... took me a while to figure it out.
Basically you need to edit /conf/base/var/cron/tab/root
However, the syntax is a little different, you don't need to specify the username...
So, lets go ahead and do mount -uw / so that you can create and edit the file /conf/base/var/cron/tab/root
Put the following in the root file (you will need to manually create the root file)
Code:
# # $FreeBSD: src/etc/crontab,v 1.33.2.1 2009/08/03 08:13:06 kensmith Exp $ # SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/mnt/FREENAS/torrent/bin # Remove completed torrent from Transmission */30 * * * * rm_completed_bt.sh >> /mnt/FREENAS/torrent/bin/cron.log 2>>&1
Reboot, and after it finish rebooting type the following:
Code:
freenas# crontab -l
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/mnt/FREENAS/torrent/bin
# Remove completed torrent from Transmission
*/30 * * * * rm_completed_bt.sh >> /mnt/FREENAS/torrent/bin/cron.log
You should see the cron job is being loaded in the list.
PS: The log file is optional, you can simply comment it out from the script.
Cheers!