I want to execute a FreeBSD shell command every time OPNsense has started. I have tried to add a @reboot crontab job, but the crontab seems to be 'cleaned' after each reboot. My @reboot is no longer in the crontab -l after a reboot.
Maybe I can use RC in some way. If so, is there any good tutorial or easy example RC-file how to create an RC job in an OPNsense FreeBSD machine (I'm have not much experience using FreeBSD or Linux)? I did read that a bad RC job might halt the startup sequence. That made me a bit cautious playing around in the RC directories.
Maybe there is a plugin I can use from within OPNsense doing a startup script/shell command?
Best Regards
- Per HÃ¥kansson
Sorry, I have no solution for you. The fact that the "Cron" setting in the UI does not let you create arbitrary cron jobs is driving me nuts as well.
Does someone know the reasoning behind this?
Kind regards,
Patrick
Add a file here:
/usr/local/etc/rc.syshook.d/start
For crontab add a file here:
/usr/local/opnsense/service/conf/actions.d/
(and give it a description)
Yes, yes, yes . . . it seems to work great!! Thanks, mimugmail!
In the /usr/local/etc/rc.syshook.d/start directory, I copy the 90-cron.. job to 93-all-service-restart and edit the file to:
#!/bin/sh
echo -n "Restart all services: "
configctl service reload all
This result in a startup output as follows:
>>> Invoking start script 'all-service-restart'
Restart all services: OK
. . . and guess what, as soon as the "Restart all services" start to execute, even before the "OK", my VXLAN starts to work :) This will fix my VXLAN remote bridge 'bug' for now.
Will this file survive an OPNsense update? . . or will the update/upgrade process wipe my new start file (93-all-service-restart)? Should I be worried to lose this fix after I update/upgrade OPNsense to next release? Does anyone know?
Once again, thanks a lot. This is great. I now can go on to test encrypting my site to site VXLAN traffic.
Best regards
- Per HÃ¥kansson
It will surive :)
But a Bug report would be nice too
Was the bug report ever posted? I had the same problem today, where my Cloudflare DynDNS script with @reboot was removed from crontab with the OPNsense upgrade.
There isn't much of a bug report for VPN and remote tunnels not coming up upon start there is some edge case in required connectivity often with dynamic WAN use such as DHCP or PPPoE which comes up too late. Not everything can be fixed.
Cheers,
Franco