r/sonarr•
gillon

Issue running Custom Script on Sonarr

Hi,

The original issue I'm trying to resolve:

  1. Sonarr tells Deluge to download - works.
  2. Upon download complete Deluge will unrar if needed - works.
  3. Sonarr will the import the unrar'd file - works.
  4. Sonarr runs a script made to cleanup the unrar'd file in torrent folder after successful import - does not work.

Some relevant info on my setup;

I've got Sonarr and Deluge running in Docker containers off my Synology NAS. Sonarr has permissions working so far as I can tell as it can read and write to necessary folders fine.

The script currently has -rwxrwxrwx permissions, so should be executable.

The script is found OK on path I specified as the 'Test' function works.

When checking logs after it's supposed to have run a script it just declares that it failed to run script with status 255.

The script in question is Fryfrog's - https://gist.github.com/fryfrog/94716e7e27ba38dff57c7631d9f58bed

I've tried everything I could come up with or that I found through googling - any ideas on what the issue could be?

Posted Dec 26, 2019, 11:19 PM UTC

68
SlyOracle•

Are you running it on Sonarr V2 or V3? V3 is still in development, but this makes a significant difference on how the Custom Script function works. Also, are you using the correct notifiers?? On Download and On Upgrade are the two you need I believe.

1
gillonOP•

V2, so the 'Test' function doesn't actually test anything other than that the script is found; I'm on master branch so I might switch to Beta to test that.

Yeah, Download and On Upgrade are only times it's run.

1
zzwdup•

I think I've dealt with something similar before.

Check the 'Completed Download Handling' settings under download client

  • make sure sonarr 'moves' the file it extracts to the destination (rather than copy)
  • Make sure the original files being deleted are not locked or in use by the system - ie. seeding (locked by torrent client)

Maybe try stopping the torrent client and then execute the script to see if it works?

1
gillonOP•

How do I set it up to move instead of copy? And won't that mean it'll move the torrent data; rather than what was actually extracted?

The script has functionality for sleeping until it's fully unpacked. The issue is that the script isn't even launched, at all.

1
PearsonFlyer•

It will not move instead of copy, if the file is your download. That means that if an unrar was needed, it should be able to move because that unrared file is NOT your download.

Are you sure the script isn't launched, or is it failing for the same reason that Sonarr would - i.e. the file is in use (being seeded)?

1
gillonOP•

Well, Sonarr log explicitly says it failed in launching the script; and none of the script echos are visible in the trace log (not sure if they're supposed to be in Sonarr logs though..).

1
zzwdup•

Since you are using a docker setup on Synology maybe you need to modify the script to tell Sonarr how to execute the script? I found this while searching google..

"It’s possible Sonarr doesn’t know how to execute it (which shell to use), in that case you’d set the script path to the shell to run and the arguments to whatever is required to execute that script. I’m not sure exactly sure what that would look like though."

I would look into 'what user/group is trying to execute the script', does Sonarr have the same access/permission to do so? you mentioned you could execute this on your test, I'm assuming this was done via your admin access? (via ssh?) Does Sonarr use the same account? Can you emulate the account and access Sonarr is using and try executing the script from a shell window?

Can you enable debug logging on Sonarr and see if it returns any more info?

FYI - Just throwing ideas at you, while I tinker with Linux/Docker and these setups I'm far from knowing exactly what I'm doing.

1
gillonOP•

I would look into 'what user/group is trying to execute the script', does Sonarr have the same access/permission to do so? you mentioned you could execute this on your test, I'm assuming this was done via your admin access? (via ssh?) Does Sonarr use the same account? Can you emulate the account and access Sonarr is using and try executing the script from a shell window?

You supply UID and GID to the container environment. I've made sure I give it the same ones I'm using.

Can you enable debug logging on Sonarr and see if it returns any more info?

Yeah, it only really states that it failed to launch the script (qoute) and gives a status code of 255.

When connecting to the NAS through SSH and running the script I do get errors because of \r characters, so I might look closer at it and see if that's the actual issue... that would be weird though as I'm stealing the script from someone who has it working.

1