Page 1 of 2
Should be simple?
Posted: April 8th, 2019, 11:39 pm
by LakersFan
Hey folks,
I have a script in unraid that works fine from a terminal, but not when used as a post-processing script in SAB.
Code: Select all
#!/bin/bash
#----------------------------------------------------------------------------
# Here you can add your own custom script eg. |
# rclone copy /local/path remote:path # copies /local/path to the remote |
# rclone sync /local/path remote:path # syncs /local/path to the remote |
#----------------------------------------------------------------------------
rclone sync /mnt/user/stern dropbox:misc
When I try to run it as a post-processing script in SAB, it fails and I get this error:
ScriptExit(-1) Cannot run script /config/scripts/db_sync.sh
Ultimately I want SAB to tell rclone (after something is done downloading), to sync with dropbox. Any help would be great.
Re: Should be simple?
Posted: April 9th, 2019, 12:01 am
by OneCD
Is your script marked as executable? Please post the existing permissions.
When you run it at the CLI, what exactly are you typing?
Re: Should be simple?
Posted: April 9th, 2019, 10:44 pm
by LakersFan
Yes, I opened a terminal and typed:
Code: Select all
chmod +x /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh
After typing it, I don’t get a response; no error or nothing saying it worked. Not sure if that is normal behavior.
In a CLI, I type “rclone sync /mnt/user/stern dropbox:misc” and it works.
Lastly, I am not sure how to obtain my existing permissions. Any guidance would be great.
Thank you!
Re: Should be simple?
Posted: April 10th, 2019, 12:30 am
by OneCD
LakersFan wrote: ↑April 9th, 2019, 10:44 pm
Yes, I opened a terminal and typed:
Code: Select all
chmod +x /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh
After typing it, I don’t get a response; no error or nothing saying it worked. Not sure if that is normal behavior.
Yes, that's the correct behaviour. Linux shells generally work on the idea that if the operation worked properly, nothing is shown. If there was a problem, you'll get an error message. It seems odd, but you get used to it.
LakersFan wrote: ↑April 9th, 2019, 10:44 pm
In a CLI, I type “rclone sync /mnt/user/stern dropbox:misc” and it works.
OK, you're running the command contained
within the shell-script, but you're not running the shell-script itself.
You can run your shell-script by specifying the absolute pathname to it (like you did when using chmod):
Code: Select all
/mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh
Or, if you're already in the correct directory:
Code: Select all
cd /mnt/cache/apps/binhex-sabnzbdvpn/scripts
... then run it like this:
LakersFan wrote: ↑April 9th, 2019, 10:44 pm
Lastly, I am not sure how to obtain my existing permissions. Any guidance would be great.
There are various ways to check this, but a simple long directory listing is sufficient:
Code: Select all
ls -l /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh
... or, if you're already in the correct directory, use:
Please post back what you see.
Re: Should be simple?
Posted: April 10th, 2019, 11:36 pm
by LakersFan
Okay, after running the shell-script, I get:
Code: Select all
root@Tower:~# /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh
-bash: /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh: /bin/bash^M: bad interpreter: No such file or directory
And for my permissions:
Code: Select all
root@Tower:~# ls -l /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh
-rwxrwxrwx 1 nobody users 453 Apr 3 22:04 /mnt/cache/apps/binhex-sabnzbdvpn/scripts/db_sync.sh*
Hopefully you can make some sense of this. lol
Re: Should be simple?
Posted: April 10th, 2019, 11:42 pm
by OneCD
Permissions look good.
The error you’re seeing when attempting to run the shell-script is because it was written with a text-editor that didn't use the correct Unix line-ending character (LF). Instead, it’s using the standard DOS characters (CR+LF).
You can either:
- edit in Windows but with a Unix compatible text editor like Notepad++,
- you can convert your shell-script file within your Linux system with ‘dos2unix’,
- or you can just edit that file within the Linux host system. Nano is a nice, simple text file editor that runs on Linux.
Re: Should be simple?
Posted: April 11th, 2019, 12:08 am
by LakersFan
Okay, some progress... I did reset Notepad++ to Unix (it was on Windows by default), re-set the permissions and now I'm getting this in SAB:
Code: Select all
Exit(127) /config/scripts/dropbox_sync.sh: line 2: rclone: command not found
When running from a CLI, it appears to run as it should. No response after typing it and files seem to be synced up.
Re: Should be simple?
Posted: April 11th, 2019, 12:19 am
by OneCD
May I suggest a change to your script?
Edit it so the first line says this:
Then try manually running your script again.
Re: Should be simple?
Posted: April 11th, 2019, 12:30 am
by LakersFan
I did that and manually ran it. It ran without errors. I then tried it in SAB and got the same 127 error as before. Then I tried setting permissions again and got this??? After permissions were denied, I ran the code you gave me earlier so you can look at the permissions.
Code: Select all
root@Tower:~# chmod -x /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh
root@Tower:~# /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh
-bash: /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh: Permission denied
root@Tower:~# ls -l /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh
-rw-rw-rw- 1 nobody users 60 Apr 10 22:21 /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh
root@Tower:~#
side note -- I have to get up super early tomorrow so I'm off to bed. Thank you for the help tonight, hopefully we can pick it back up tomorrow.
Re: Should be simple?
Posted: April 11th, 2019, 12:47 am
by OneCD
You'll need to set the execute bit again for your script. It looks like it's got a new filename. Also
+ enables,
- disables:
Code: Select all
chmod +x /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh
You might also investigate including the complete path to your 'rclone' binary. To find this:
Then prefix the 'rclone' command in your script with the path shown.
BTW: you're nearly there.
Re: Should be simple?
Posted: April 11th, 2019, 11:53 pm
by LakersFan
I do feel close!
Thanks for the tip on the permissions. I got that worked out with the +x instead of -x.
I did the "which rclone" command and it came up with /usr/sbin/rclone
So I changed my script to this... (not sure if that's what you meant my prefixing the path):
Code: Select all
#!/usr/bin/env bash
/usr/sbin/rclone sync /mnt/user/stern dropbox:misc
I am still getting the error in SAB:
Code: Select all
ScriptExit(127) /config/scripts/dropbox_sync.sh: line 2: /usr/sbin/rclone: No such file or directory
Re: Should be simple?
Posted: April 12th, 2019, 12:37 am
by OneCD
Re: prefixing the path - that's exactly right.
OK, let's do some detective work. Please modify your shell-script so it looks like this (copy and paste it into your editor):
Code: Select all
#!/usr/bin/env bash
#/usr/sbin/rclone sync /mnt/user/stern dropbox:misc
{
echo "date: $(date)"
echo "PATH: $PATH"
echo "EUID: $EUID"
echo "which: $(which rclone)"
echo "check direntry: $(ls -l /usr/sbin/nologin 2>&1)"
echo "rclone direntry: $(ls -l /usr/sbin/rclone 2>&1)"
echo
} >> /tmp/db-sync.log
Then run your script manually.
Afterward, check the logged output with:
Then, get SABnzbd to run it as a post-processing script, and check the log file contents again (the new logged values will be appended to the original log).
Are the recorded values the same for the manual run as for the SABnzbd post-processing run?
Re: Should be simple?
Posted: April 13th, 2019, 12:11 am
by LakersFan
Yes, they are the same.
Code: Select all
Linux 4.18.20-unRAID.
Last login: Thu Apr 11 21:46:41 -0700 2019 on /dev/pts/5.
root@Tower:~# /mnt/cache/apps/binhex-sabnzbdvpn/scripts/dropbox_sync.sh
root@Tower:~# cat /tmp/db-sync.log
date: Fri Apr 12 22:07:40 PDT 2019
PATH: .:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
EUID: 0
which: /usr/sbin/rclone
check direntry: ls: cannot access '/usr/sbin/nologin': No such file or directory
rclone direntry: -rwxr-xr-x 1 root root 495 Apr 7 15:04 /usr/sbin/rclone
root@Tower:~# cat /tmp/db-sync.log
date: Fri Apr 12 22:07:40 PDT 2019
PATH: .:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
EUID: 0
which: /usr/sbin/rclone
check direntry: ls: cannot access '/usr/sbin/nologin': No such file or directory
rclone direntry: -rwxr-xr-x 1 root root 495 Apr 7 15:04 /usr/sbin/rclone
root@Tower:~#
Re: Should be simple?
Posted: April 13th, 2019, 12:19 am
by OneCD
OK, it seems the SAB post-processor hasn't run your script. There should be a second series of entries in that log file starting with a different datetime.
Can you please confirm you ran the script as a post-processor within SABnzbd?
Re: Should be simple?
Posted: April 13th, 2019, 12:28 am
by LakersFan
Here's a screenshot showing it was ran: