Run a script at startup

I have tried to find a solved post on this topic, and I’m sorry if I was unable. I would like to run a script at startup (advertise a route on tailscale) but without using the autorun.sh solution as the Security Center marks the “Run user defined processes during startup” as an “High Level Risk”. Thanks!

Disable/Remove security center…that should solve it.

Hi @arico
The Autorun warning flags potential risks. If you can, please share the commands you plan to use. This helps us suggest best practices.

You can customize rules in Security Center to manage these warnings based on certain principles. We are also planning a new FAQ to provide more details on this.

Thanks!

Hi SteveKo,

the command inside the autorun.sh was just a

#!/bin/sh
/share/CACHEDEV1_DATA/scripts/autorun.sh

The command in the scripts/autorun.sh was:

#!/bin/sh
/share/CACHEDEV1_DATA/.qpkg/Tailscale/tailscale up --advertise-routes=192.168.XX.0/24 --accept-routes

to just advertise a route with Tailscale. I know that the warning is “correct”, I can see why it is a security risk. I’m not looking for a way to avoid the warning, I know how to do it. And I do not need a reason to accept that is a risk.

I just wanted to know if there is a “secure” way to run a custom script when the nas reboots. Thanks!

Hi @arico, with regard to the autorun.sh script, please note: it executes before QPKGs (like Tailscale) are started, so you may find your command will fail.

At-present, there isn’t a built-in facility for running scripts after all QPKGs have been started during the NAS boot process, but this would be a handy feature to have.

Thanks @OneCD,

in fact I used a sleep(x) to delay the execution of the command. I second you, as a built-in feature would be great!

Using sleep in autorun.sh causes autorun to pause, as it doesn’t execute asynchronously.

At-least, it didn’t last time I checked this. QNAP made some enhancements in QTS 5.2.0 to launch QPKGs asynchronously, so maybe they changed how autorun works too.

If it works for you, great! :nerd_face: