Recommended place for user created shell scripts?

Started by Patrick M. Hausen, July 24, 2020, 08:31:56 AM

Previous topic - Next topic
Hi all,

if I want to set up some custom cron jobs, is there an official recommendation where to put them?
My main concern is that I want them to survive a firmware upgrade, of course.

Thanks,
Patrick
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Hi Patrick,

Add your scripts somewhere and register actions for them like so:

https://docs.opnsense.org/development/backend/configd.html

When you use a "description" these actions (your scripts) will show up in the System: Settings: Cron GUI for use.


Cheers,
Franco

Hi Franco,

I don't need UI access. It's only cron jobs. I just wanted to be sure the next upgrade won't wipe e.g. /usr/local/sbin/myscript.sh or similar.

I guess placing them into /home somewhere will do.

Thanks,
Patrick
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Ah ... now I get it. I assumed that System --> Settings --> Cron would let you specify arbitrary commands.
Seems like it doesn't.

Thanks again
Patrick
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

You can't manipulate cron without a defined backend action. Config files will revert defaults otherwise. That's why this is a bit more work initially, but can be automated as a plugin package if mass deployment is relevant. :)

We generally avoid the ability to tie custom scripts to working code directly, especially through config.xml.

Separate files and scripts are never touched by the system unless the file name appears in the packages at some point in time. Just make sure to create a separate directory that is unlikely to ever appear (i.e. /usr/local/mycoolscripts)


Cheers,
Franco