transmission-daemon - Run script when torrent is done - scp

Feature requests not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
fedxc
Posts: 4
Joined: Wed Nov 09, 2011 11:11 pm

transmission-daemon - Run script when torrent is done - scp

Post by fedxc »

I was using the GUI version of Transmission for Ubuntu.
When my torrents were downloaded I ran the following script as user server with the corresponding ssh keys:

Code: Select all

#!/bin/bash

# Log file
  LOG_FILE=/home/server/Downloads/move.log
  echo $(date +%Y-%m-%d\ %H:%M:%S) >> $LOG_FILE
  echo "***Running move.sh***" >> $LOG_FILE

cd "/home/server/Downloads"
find . -type f | while IFS= read filename; do # Look for files in all ~/Downloads sub-dirs
case "${filename,,*}" in  # this syntax emits the value in lowercase: ${var,,*} 
     *.part) : ;; # Excludes *.part files from being moved
	 *.resume) : ;;
	 *.torrent) : ;;
	 *.trashinfo) : ;;
	 move.sh) : ;;
# Include
     *document*) scp "$filename" "imac@imac.local:/users/imac/Documents/" && rm "$filename" && echo "$filename moved and deleted" >> $LOG_FILE;;
# Else
     *) echo "Don't know where to put $filename" >> $LOG_FILE;;
  esac
done
Now I'm using transmission-daemon and the script is not executed as server anymore, therefore, scp does not work because when trying to ssh to imac@imac.local it prompts for a password (no ssh key for that user).

How can I fix this problem?
Thanks!

Edit: I think I should have posted on Support. Sorry, my first post here.
gunzip
Posts: 272
Joined: Wed May 05, 2010 2:12 am

Re: transmission-daemon - Run script when torrent is done -

Post by gunzip »

try this..

Ubuntu - How to connect with ssh without using a password

just do the procedure as user "transmission-daemon" (assuming that is correct user name), i.e.

$ sudo su transmission-daemon
killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: transmission-daemon - Run script when torrent is done -

Post by killemov »

gunzip wrote:try this..

Ubuntu - How to connect with ssh without using a password

just do the procedure as user "transmission-daemon" (assuming that is correct user name), i.e.

$ sudo su transmission-daemon
Ah, but the problem is probably that the target machine is a Mac. You need to find a way to accept ssh requests with ssh keys only.

Why push the files to a Mac and not pull the files from the server? (On demand instead of on downloaded.)
Why download on one machine and transfer to another? Maybe download on the other machine, the Mac?
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: transmission-daemon - Run script when torrent is done -

Post by blacke4dawn »

killemov wrote:Ah, but the problem is probably that the target machine is a Mac. You need to find a way to accept ssh requests with ssh keys only.
He had it working before he switched to the deamon version, from the GUI version, so that would not be the problem, especially when you consider that the daemon uses it's own account by default.
killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: transmission-daemon - Run script when torrent is done -

Post by killemov »

blacke4dawn wrote:
killemov wrote:Ah, but the problem is probably that the target machine is a Mac. You need to find a way to accept ssh requests with ssh keys only.
He had it working before he switched to the deamon version, from the GUI version, so that would not be the problem, especially when you consider that the daemon uses it's own account by default.
Then a probable solution is in your reply: The ssh key needs to be regenerated for the daemon account.
fedxc
Posts: 4
Joined: Wed Nov 09, 2011 11:11 pm

Re: transmission-daemon - Run script when torrent is done -

Post by fedxc »

Thanks for your replies. I know there are other solutions, this is temporary. One of my server hard drives broke and I have to store things on my Mac.

You are right, the ssh key needs to be regenerated for the daemon account.

I tried this instead:

Code: Select all

scp -i /home/server/.ssh/id_rsa "$filename" "imac@imac.local:/users/Documents
This works ok with every user I tried. But is does not work when transmission executes the script.

I added this command to my scirpt so I could log the user transmission-daemon is using: "echo "$USER" >> $LOG_FILE"

But it returns an empty line, I don't know what user is running this script.
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: transmission-daemon - Run script when torrent is done -

Post by blacke4dawn »

I would try:

Code: Select all

echo "Effective user: $(id -n)" >> $LOG_FILE
echo "Real user: $(id -nr)" >> $LOG_FILE
That should give all relevant user names to work from and give some insight in how transmission is started and run.
fedxc
Posts: 4
Joined: Wed Nov 09, 2011 11:11 pm

Re: transmission-daemon - Run script when torrent is done -

Post by fedxc »

Still blank:
Effective user:
Real user:
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: transmission-daemon - Run script when torrent is done -

Post by blacke4dawn »

Default user account for the transmission daemon on Ubuntu is "transmission-daemon", so try that one.

But I have to ask, why not share the folder that is used on the Mac and just mount it somewhere on the Ubuntu machine?
fedxc
Posts: 4
Joined: Wed Nov 09, 2011 11:11 pm

Re: transmission-daemon - Run script when torrent is done -

Post by fedxc »

Didn't thought about that.

How do I mount my imac shared dir?
killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: transmission-daemon - Run script when torrent is done -

Post by killemov »

fedxc wrote:Didn't thought about that.

How do I mount my imac shared dir?

Code: Select all

mount -t cifs -o username=myusername,password=mypassword //myremoteip/myremotepath /mylocalpath
Post Reply