How to do a script for QNAP NAS that would automatically mount remotes in Plex at Startup

Hello!
I have been trying for quite a few days to come up with a script that would allow to mount remotes with Rclone in Plex during QNAP NAS startup. Keep in mind that I don´t know anything about linux but I was able by copying and paste a few commands from the tutorials to finally mount remotes in Plex.

The problem is that when I restart my QNAP NAS everything is gone and I would have to setup all the remotes from scratch all the times. Is there any way that you could help me out with this please? I would need just some step by step instructions on how to accomplish this.

Thank you very much!

I'm not a qnap expert so I've made this topic public in the hope someone else can help .

Thank you nwc! I appreciate it

I know even less about QNAP, than Nick I suspect, but maybe I can help on a more general level.

QNAP is as far as I know based on Linux right? So it would be fair to assume that some of the fundamentals operate the same, albeit with some twists here and there.

Normally I think remotes in Linux are persistent right @ncw? Unlike Windows you actually have to dis-mount them to make them go away? This might be something that is different in QNAP though, and thus you might need a solution more like what I use on Windows - ie. a mount-on-boot script.That is certainly doable, and and setting it up as a service might be the remedy.

Can you elaborate on what you mean when you say "everything is gone" when you reboot?
Is rclone itself gone?
Is the rclone config-file empty?
Or do you just mean that the mount you set up is not active anymore?

If it is the last one then the solution may be relatively simple, but if it's one of the former we have to dig a bit deeper into what is going on.

as this is a linux/qnap question, perhaps you might want to post the question to the qnap forum.

https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup

Hey thestigma!

Thanks for helping me out. Yes, the answer to your question is that after NAS restart all the remotes I have setup are gone but Rclone is still there and working fine. Specifically, I need a script to edit the content of a QNAP script called autorun.sh that is used by the system to start applications and processes at every startup. To know what I am talking about, please take a look at this link: https://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup

I have followed all the steps outlined in that link but when it comes to actually edit the autorun.sh I wouldn´t have any idea on how to do that. That is the main hurdle for me and I can´t get over it. I am sure some of you guys can easily do it. My problem is that I don´t know anything about Linux at all :slight_smile:
Thanks for any help, really!

thanks asdffdsa! I actually just mentioned that linked in my post. That page is very helpful but I have no idea how to edit the autorun.sh script

yeah, small world, i just posted the link and then you post the same link one minute later.

let's break this problem into steps.
step 01 = must be able to remote login to the qnap via ssh or telnet
can you do that ?

yes I was able to ssh into my QNAP NAS and also able to setup a drive, cache and crypt remotes this is what I mean:

[~] # rclone config
Current remotes:

Name Type
==== ====
gcache cache
gcrypt crypt
gdrive drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q>

good,
so what is the problem,
step 02 = edit autorun.sh.

Sounds like our best bet is to just make rclone run the mount in the autorun.sh script then. That seems like it should be fairly simple if we just can see what format it is in.

Assuming that it does not contain a lot of sensitive information - can you share the contents of that file with us? Either post it here, or on pastebin if it is really long. Hopefully the format is simple enough that we can suggest how to insert an rclone mount command into it.

PS: If you want to show us your rclone configuration then the best way is to copy the contents of rclone.config - but please do redact the most sensitive information first for the sake of your privacy. Especially any crypt-keys or passwords. If your mount is working fine when you start it manually I don't necessarily think you need to share it to fix this problem though. Up to you :slight_smile:

exactly asdffdsa! I don´t know how to keep the remotes active even after I restart my QNAP NAS

Sorry guys, this is what I mean about being a newbie at this.... how do I open the file rclone.config to see the content?

yesterday, i updated the firmware on a qcrap, err, i mean, qnap, of a client of mine, and there is a new software package that might do what you want without messing around with rclone and autorun.sh

Hello asdffdsa, yes I have installed that program and it is actually really cool because it allows you to mount a GDrive volume inside the File Station application. The problem is that when you try to create a new library in Plex and open up a volume to link the files, that googledrive volume is not showing up in the directory

Hey stigma, I tried to open up the autorun.sh file but it is totally empty

cool,
as for gdrive and plex, i know less then zero about them.

as for the autorun.sh file, i think that it should be empty the first time you open it.
add you rclone command to that file...

Yes that what I was imagined doing but how though? When I mounted the volumes in rclone I have done that by answering questions that are presented step by step by the program. I have seen that people have been compacting all those commands into one line of text. That is what I don´t know how to accomplish

ah, for that, you need @thestigma and his high verbosity level,
you can add multiple lines to the autorun.sh file.