Transmission, Sick Beard, CouchPotato (Drobo 5N)

I have been tooling around for the past few weeks basically trying to emulate the Usenet bundle, that Ricardo has been so kind to make, but using torrents. I wanted to document what I have done here for anyone else that might be interested.

The following bit about Transmission is really only useful for cross-compiling and my experience in doing such, now that Transmission is an official DroboApp the next section is largely unneeded but I will leave it here for reference.

[quote]First I knew I wanted to try my hand at cross compiling for the Drobo and for that, Ricardo and DroboPorts were invaluable. So I set off to compile Transmission for the Drobo 5N and at the time noticed the version on DroboPorts was not the latest version so I followed the instructions for cross compiling Transmission replacing the following section:

wget -O transmission-2.73.tar.bz2 http://download.transmissionbt.com/files/transmission-2.73.tar.bz2
tar jxf transmission-2.73.tar.bz2
cd transmission-2.73

with

wget -O transmission-2.77.tar.bz2 http://download.transmissionbt.com/files/transmission-2.77.tar.bz2
tar jxf transmission-2.77.tar.bz2
cd transmission-2.77

2.77 being the latest version at the time. There is now a 2.77 versions on DroboPorts so it would be much easier to use that instead, however, I encourage anyone with the time and even the slightest interest to cross compile something, it was not a bad experience, taught me a lot and brought a new appreciation for the whole process.[/quote]

Update (04/05/2014)
The above I will keep in case any one was/is interested in my experience, however Transmission is now an official app in the Drobo Dashboard.

For Sick Beard and CouchPotato I just followed the DroboPorts instructions for those. I didn’t install SABnzbd or Headphones.
The above are now official apps in Drobo Dashboard

Unique to torrents however is the need/want to seed the content, which is what I have been trying to make work before I made this post.
Sick Beard, if set to keep the downloaded files and also process will never stop processing and continually copy and overwrite from the download location to the library location.
I came across this fix which as far as I can tell has not been merged into the source yet but does indeed solve the issue so torrents can continue seeding and Sick Beard only processes the files once. To apply the fix I stopped Sick Beard renamed the postProcessor.py, postProcessor.pyc, processTV.py and processTV.pyc and copied over the updated versions of those 2 files. For this fix to work Sick Beard > Config > Post Processing settings need to be set to “Keep Original Files” otherwise it seems the “.processed” files won’t be created and if you also follow the hardlink script below will result in some bad behavior without this setting checked.

Update (04/05/2014)
The above fix is no longer needed now that a fix has been merged into the development and master branches of Sick Beard.

Also to try to be a bit more efficient I turned off Sick Beard’s auto scan and process option and wrote a script to trigger the scan and process only after a torrent is completed.
Updated (04/05/2014)
I have further modified the below script to unrar any archived it finds in the Sick Beard download directory of the finished torrent before triggering Sick Beard.
This of course requires unrar to be installed to the Drobo which I downloaded from DroboPorts.
Please note to change the USER:PASS for your Sick Beard install if you have one set and any directories if they are different from the defaults.
I created a “scripts” directory in transmission/data/ in here I put the complete.sh script containing the following code:

#!/bin/sh

# These are inherited from Transmission.
# Do not declare these. Just use as needed.
# TR_APP_VERSION
# TR_TIME_LOCALTIME
# TR_TORRENT_DIR
# TR_TORRENT_HASH
# TR_TORRENT_ID
# TR_TORRENT_NAME

# The file for logging events from this script.
LOGFILE="/mnt/DroboFS/Shares/DroboApps/transmission/var/log/complete.log"

# WGET directory
WGET="/mnt/DroboFS/Shares/DroboApps/wget/bin/wget"

# UNRAR directory
UNRAR="/mnt/DroboFS/Shares/DroboApps/unrar/bin/unrar"

edate() {
  echo -e "$(/bin/date '+%Y-%m-%d %H:%M:%S') ${1}" >> "$LOGFILE"
}
 
# Update log
edate "${TR_TORRENT_DIR}${TR_TORRENT_NAME} is completed, sleeping for 65 seconds."
sleep 65

# Check if finished torrent was for Sick Beard
if [ "${TR_TORRENT_DIR}" == "/mnt/DroboFS/Shares/Torrents/Downloads/(Sick Beard)/" ] || [ "${TR_TORRENT_DIR}" == "/mnt/DroboFS/Shares/Torrents/Downloads/(Sick Beard)" ]; then

	# Checking for RAR archive.
	FOUND_RAR=$(/usr/bin/find "${TR_TORRENT_DIR}${TR_TORRENT_NAME}/" -maxdepth 1 -type f -iname "*.rar")

	if [ "${FOUND_RAR}" ]; then
		edate "Found RAR: ${FOUND_RAR}, extracting contents to ${TR_TORRENT_DIR}${TR_TORRENT_NAME}/"
		$UNRAR e -y -p- -o+ "${FOUND_RAR}" "${TR_TORRENT_DIR}${TR_TORRENT_NAME}/"
		edate "Sleeping 65 seconds."
		sleep 65
	fi

	edate "Awake, telling Sick Beard to process downloads in ${TR_TORRENT_DIR}\n"
	$WGET -qO /dev/null "http://USER:PASS@localhost:8081/home/postprocess/processEpisode?dir=${TR_TORRENT_DIR}"
else
	edate "File is not for Sick Beard and was not processed by Sick Beard.\n"
fi

The LOGFILE can be changed to anywhere you desire I just put it with transmission also the WGET path may need changed if it’s in a different location. Also note if you have a username and password set for Sick Beard those will need to be replaced in the link and at the end of the link change the path to the directory that processing is requested.
I had to allow 777 on the log directory in DroboApps/transmission/var so transmission could write the sickbeard.log this is entirely optional the LOGFILE in my script can be commented out I just have it logging the date, time, what torrents is complete and to see if it was sleeping properly for a minute before triggering Sick Beard. I have it sleep just in case Transmission is finishing flushing data before Sick Beard tries to process.

To run this script after Transmission completes a download you will need to stop Transmission and edit the transmission/data/settings.json file and look for the 2 lines “script-torrent-done-enabled” and “script-torrent-done-filename” lines and set “script-torrent-done-enabled” to true and set “script-torrent-done-filename” to the path to your script. Mine looks like this:

"script-torrent-done-enabled": true, 
"script-torrent-done-filename": "/mnt/DroboFS/Shares/DroboApps/transmission/data/scripts/complete.sh", 

The last issue I came up against was permissions.
I based my permissions off of Ricardo’s system (post #24).

I SSH into the Drobo 5N and did the following:
I added a media group: “addgroup media”
Added Sick Beard user To media user group: “addgroup sickbrd media”
I used this to check my addgroup worked it shows all members of group media: “grep ^media /etc/group”
I navigated to my shares: “cd ~/Shares” which is were I changed the group owner
Changes the group ownership of my media and torrent directories: “chgrp -R media Media” (this will be your media directory/share) “chgrp -R media Torrents” (torrent directory/share)
This lists the permissions I used to check my group ownership and permissions settings: “ls -al”
This sets the permissions and inheritance: “chmod -R 2775 Media” (this will be your media directory/share) “chmod -R 2775 Torrents” (this will be your torrent directory/share)

I needed to allow Sick Beard to write to the torrent directory for that fix above to work as it writes a .PROCESSED file to the directory so next time it knows the file has already been processed that is why I added the group to my torrent directory and gave it write permission. I already had files in the torrent directory but on a new install it shouldn’t be necessary if in the transmission settings.json umask is set to 0 allowing for world writable.

Updated (04/05/2014)
I have now added a post process script to Sick Beard to handle cleaning up extracted files from RAR archives or creating hardlinks depending on if a RAR archive exists in the downloads directory or not.
The script below has been further updated now since I no longer need the “.processed” fix as a fix has been merged into Sick Beard development and master branches.
I created a “scripts” directory in sickbeard/data/ in here I put postprocess.sh containing the following code:

#!/bin/sh

# The file for logging events from this script
LOGFILE="/mnt/DroboFS/Shares/DroboApps/sickbeard/data/Logs/postprocess.log"

edate () {
  echo -e "$(/bin/date '+%Y-%m-%d %H:%M:%S') ${1}" >> "$LOGFILE"
}

edate "Post-Processed file: ${1}"
edate "Source file: ${2}"
edate "Sleep for 30 seconds to ensure processing is completed."
sleep 30

# Base directory of Sick Beard processed file.
BASE_DIR=$(/usr/bin/dirname "${2}")
# Sick Beard processed file.
FILE_NAME=$(/usr/bin/basename "${2}")
# Checking for RAR archive.
FOUND_RAR=$(/usr/bin/find "$BASE_DIR/" -maxdepth 1 -type f -iname "*.rar")
# Hard link count.
HARD_LINK_COUNT=$(/bin/stat -c '%h' "${2}")

if [ "${FOUND_RAR}" ]; then
	edate "Found RAR: $FOUND_RAR"
	edate "Base DIR: $BASE_DIR/"
	edate "RAR archive found, checking for extracted file: ${2}"
	if [ -e "${2}" ]; then
		edate "Removing extracted processed file: ${2}\n"
		/bin/rm -r "${2}"
	else
		edate "Extracted file ${2} is not a file or doesn't exist, doing nothing.\n"
	fi
else
	edate "No RAR archive found."

	# Detect if Hard link exists, if none are found remove original file and create Hard link.
	if [ $HARD_LINK_COUNT -le 1 ]; then
		edate "${2} not detected as Hard link."
		edate "Removing original file: ${2}"
		/bin/rm -r "${2}"
		edate "Creating Hard link ... Source: ${1} Link: ${2}\n"
		/bin/ln "${1}" "${2}"
	else
		edate "File is already a hard link, no post processing necessary.\n"
	fi
fi

Again the LOGFILE can go anywhere or you can remove it completely. To run this script after Sick Beard processes the file(s) you will need to stop Sick Beard and edit the sickbeard/data/config.ini and look for the “extra_scripts” line and update it with the path to your script. Mine looks like this:

extra_scripts = /mnt/DroboFS/Shares/DroboApps/sickbeard/data/scripts/postprocess.sh

So what happens is Transmission completes then logs what was completed and checks for a RAR archive, if one is found it will attempt to extract the contents to the same directory after which it will manually trigger Sick Beard to process the files. Once Sick Beard is done the post process script will check if a RAR archive exists and if so will delete the file that it previously processed leaving the RAR archive and unfortunately any other files that were extracted that were not processed by Sick Beard as I am using the 2 files Sick Beard passes to the scripts, the source file and destination file. It which point they will continue seeding.
If the file was not from a RAR the script will delete it and create a hardlink in its place linking to the processed file in it’s final location in your library, at which point seeding will continue and drive space will be spared having a single copy of the file for seeding and entertainment.

[size=large]WARNING:[/size]
While these scripts work for me they make not work for everyone I would now consider these beta scripts and if any one has any suggestions and or improvements please don’t hesitate to share! So please be careful and make sure the fix I mentioned above where Sick Beard leaves a “.processed” file is implemented.

CouchPotato seems to just work once it’s setup with Transmission as a downloader, I can try to help with any specific questions but I don’t recall doing anything special other than setting permissions.
I added the CouchPotato user “couchpot” to the “media” group just like above, “addgroup couchpot media”

Also for good measure I added the Transmission user “trmssion” to the “media” group “addgroup trmssion media”

One final note was I wanted to keep users and groups on reboot which Ricardo and I had a small discussion about here

The above regarding permissions is mostly useless now that these are official apps and run as root but again I will leave it here for reference.

Hope this helps anyone else interested in running a similar bundle to the Usenet Bundle but with Torrents.

I encourage anyone with the time and even the slightest interest to cross compile something, it was not a bad experience, taught me a lot and brought a new appreciation for the whole process.

For SickBeard and CouchPotato I just followed the DroboPorts instructions for those. I didn’t install SABnzbd or Headphones.

Unique to torrents however is the need/want to seed the content, which is what I have been trying to make work before I made this post.
SickBeard, if set to keep the downloaded files and also process will never stop processing and continually copy and overwrite from the download location to the library location.
I came across this fix which as far as I can tell has not been merged into the source yet but does indeed solve the issue so torrents can continue seeding and SickBeard only processes the files once. To apply the fix I stopped SickBeard renamed the postProcessor.py, postProcessor.pyc, processTV.py and processTV.pyc and copied over the updated versions of those 2 files.

There are a few fixes I came across including scripts to symbolic link which I may look into in the future but for now the above fix works well for me and stops the Drobo from thrashing hard drives.

Also to try to be a bit more efficient I turned off SickBeard’s auto scan and process option and wrote a script to trigger the scan and process only after a torrent is completed.
I created a “scripts” directory in transmission/etc/ in here I put the sickbeard.sh script containing the following

#!/bin/sh

#################################################################################
# These are inherited from Transmission.                                        #
# Do not declare these. Just use as needed.                                     #
#                                                                               #
# TR_APP_VERSION                                                                #
# TR_TIME_LOCALTIME                                                             #
# TR_TORRENT_DIR                                                                #
# TR_TORRENT_HASH                                                               #
# TR_TORRENT_ID                                                                 #
# TR_TORRENT_NAME                                                               #
#                                                                               #
#################################################################################

# The file for logging events from this script
LOGFILE="/mnt/DroboFS/Shares/DroboApps/transmission/var/log/sickbeard.log"

# WGET directory
WGET="/mnt/DroboFS/Shares/DroboApps/wget/bin/wget"

edate() {
  echo "`date '+%Y-%m-%d %H:%M:%S'` $1" >> "$LOGFILE"
}
 
#Update log and trigger SickBeard post process
edate "$TR_TORRENT_NAME is completed, sleeping for 60 seconds" >> $LOGFILE
sleep 60
edate "Awake, telling SickBeard to process downloads" >> $LOGFILE
$WGET -qO /dev/null http://USER:PASS@localhost:8081/home/postprocess/processEpisode?dir=/mnt/DroboFS/Shares/Torrents/Downloads

The LOGFILE can be changed to anywhere you desire I just put it with transmission also the WGET path may need changed if it’s in a different location. Also note if you have a username and password set for SickBeard those will need to be replaced in the link and at the end of the link change the path to the directory that processing is requested.
I had to allow 777 on the log directory in DroboApps/transmission/var so transmission could write the sickbeard.log this is entirely optional the LOGFILE in my script can be commented out I just have it logging the date, time, what torrents is complete and to see if it was sleeping properly for a minute before triggering SickBeard. I have it sleep just in case Transmission is finishing flushing data before SickBeard tries to process.

The last issue I came up against was permissions.
I based my permissions off of Ricardo’s system (post #24).

I SSH into the Drobo 5N and did the following:
I added a media group: “addgroup media”
Added SickBeard user To media user group: “addgroup sickbrd media”
I used this to check my addgroup worked it shows all members of group media: “grep ^media /etc/group”
I navigated to my shares: “cd ~/Shares” which is were I changed the group owner
Changes the group ownership of my media and torrent directories: “chgrp -R media Media” (this will be your media directory/share) “chgrp -R media Torrents” (torrent directory/share)
This lists the permissions I used to check my group ownership and permissions settings: “ls -al”
This sets the permissions and inheritance: “chmod -R 2775 Media” (this will be your media directory/share) “chmod -R 2775 Torrents” (this will be your torrent directory/share)

I needed to allow SickBeard to write to the torrent directory for that fix above to work as it writes a .PROCESSED file to the directory so next time it knows the file has already been processed that is why I added the group to my torrent directory and gave it write permission. I already had files in the torrent directory but on a new install it shouldn’t be necessary if in the transmission settings.json umask is set to 0 allowing for world writable.

CouchPotato seems to just work once it’s setup with Transmission as a downloader, I can try to help with any specific questions but I don’t recall doing anything special other than setting permissions.

One final note was I wanted to keep users and groups on reboot which Ricardo and I had a small discussion about here

Hope this helps anyone else interested in running a similar bundle to the Usenet Bundle but with Torrents.

I encourage anyone with the time and even the slightest interest to cross compile something, it was not a bad experience, taught me a lot and brought a new appreciation for the whole process.

For SickBeard and CouchPotato I just followed the DroboPorts instructions for those. I didn’t install SABnzbd or Headphones.

Unique to torrents however is the need/want to seed the content, which is what I have been trying to make work before I made this post.
SickBeard, if set to keep the downloaded files and also process will never stop processing and continually copy and overwrite from the download location to the library location.
I came across this fix which as far as I can tell has not been merged into the source yet but does indeed solve the issue so torrents can continue seeding and SickBeard only processes the files once. To apply the fix I stopped SickBeard renamed the postProcessor.py, postProcessor.pyc, processTV.py and processTV.pyc and copied over the updated versions of those 2 files.

There are a few fixes I came across including scripts to symbolic link which I may look into in the future but for now the above fix works well for me and stops the Drobo from thrashing hard drives.

Also to try to be a bit more efficient I turned off SickBeard’s auto scan and process option and wrote a script to trigger the scan and process only after a torrent is completed.
I created a “scripts” directory in transmission/etc/ in here I put the sickbeard.sh script containing the following

#!/bin/sh

#################################################################################
# These are inherited from Transmission.                                        #
# Do not declare these. Just use as needed.                                     #
#                                                                               #
# TR_APP_VERSION                                                                #
# TR_TIME_LOCALTIME                                                             #
# TR_TORRENT_DIR                                                                #
# TR_TORRENT_HASH                                                               #
# TR_TORRENT_ID                                                                 #
# TR_TORRENT_NAME                                                               #
#                                                                               #
#################################################################################

# The file for logging events from this script
LOGFILE="/mnt/DroboFS/Shares/DroboApps/transmission/var/log/sickbeard.log"

# WGET directory
WGET="/mnt/DroboFS/Shares/DroboApps/wget/bin/wget"

edate() {
  echo "`date '+%Y-%m-%d %H:%M:%S'` $1" >> "$LOGFILE"
}
 
#Update log and trigger SickBeard post process
edate "$TR_TORRENT_NAME is completed, sleeping for 60 seconds" >> $LOGFILE
sleep 60
edate "Awake, telling SickBeard to process downloads" >> $LOGFILE
$WGET -qO /dev/null http://USER:PASS@localhost:8081/home/postprocess/processEpisode?dir=/mnt/DroboFS/Shares/Torrents/Downloads

The LOGFILE can be changed to anywhere you desire I just put it with transmission also the WGET path may need changed if it’s in a different location. Also note if you have a username and password set for SickBeard those will need to be replaced in the link and at the end of the link change the path to the directory that processing is requested.
I had to allow 777 on the log directory in DroboApps/transmission/var so transmission could write the sickbeard.log this is entirely optional the LOGFILE in my script can be commented out I just have it logging the date, time, what torrents is complete and to see if it was sleeping properly for a minute before triggering SickBeard. I have it sleep just in case Transmission is finishing flushing data before SickBeard tries to process.

Asked for your original account to be unbanned. Obviously the antispam engine fears your cross-compiling shenanigans. :slight_smile:

Yeah haha, thanks. I also PM’d Sky

Heh, I would take it as a rite of passage. You aren’t really a Drobo forum veteran until you get your account mistakenly banned by the anti-spam measures.