English Forums > Tutorials and FAQs

Running custom scripts?

(1/2) > >>

ember1205:
I want my firewall to "check in" via REST API calls at boot and shutdown to an external system. At the system level, I only need to execute a curl command, but I don't know:

A) Does the root user's crontab persist "as is" across firmware updates, or is that overwritten?

B) Is there a suggested directory on the system to put a custom script into so that it doesn't get removed by the system or lost across udpates?

C) Is there a more preferable way to implement this sort of thing? The "Settings" area looks like an ideal to offer this sort of thing (especially via the Cron section) but I'm not seeing where I can run a custom script - only canned ones.

franco:
Hi,

Take a look at https://docs.opnsense.org/development/backend/autorun.html

Using other methods runs the risk of being reverted on reboot or update.


Cheers,
Franco

ember1205:
Thank you... This seems to be what I was trying to find for info.

Based on my description above for when these would need to run, it seems I should use the subdirectories of "start" and "stop"?

These should just be normal bash scripts (or similar) - correct?

franco:
Yes, start and stop. You can drop any executables into these directory, but of course scripts make the most sense. If you have strict "bash" scripts don't forget to install bash, otherwise POSIX shell/Python/Perl/PHP are all available by default.


Cheers,
Franco

franco:
PS: Might be easier to see than to talk about it... https://github.com/opnsense/core/tree/master/src/etc/rc.syshook.d/start

Navigation

[0] Message Index

[#] Next page

Go to full version