Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
General Discussion
»
How to best execute shell command once, after OPNsense have reboot?
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to best execute shell command once, after OPNsense have reboot? (Read 4237 times)
pelle
Newbie
Posts: 10
Karma: 0
How to best execute shell command once, after OPNsense have reboot?
«
on:
October 28, 2020, 09:37:44 am »
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
Logged
Patrick M. Hausen
Hero Member
Posts: 6841
Karma: 574
Re: How to best execute shell command once, after OPNsense have reboot?
«
Reply #1 on:
October 28, 2020, 09:44:13 am »
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
Logged
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do.
(Isaac Asimov)
mimugmail
Hero Member
Posts: 6766
Karma: 494
Re: How to best execute shell command once, after OPNsense have reboot?
«
Reply #2 on:
October 28, 2020, 02:01:09 pm »
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)
Logged
WWW:
www.routerperformance.net
Support plans:
https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German):
https://opnsense.max-it.de/
pelle
Newbie
Posts: 10
Karma: 0
Re: How to best execute shell command once, after OPNsense have reboot?
«
Reply #3 on:
October 28, 2020, 09:10:06 pm »
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
Logged
mimugmail
Hero Member
Posts: 6766
Karma: 494
Re: How to best execute shell command once, after OPNsense have reboot?
«
Reply #4 on:
October 28, 2020, 10:32:18 pm »
It will surive
But a Bug report would be nice too
Logged
WWW:
www.routerperformance.net
Support plans:
https://www.max-it.de/en/it-services/opnsense/
Commercial Plugins (German):
https://opnsense.max-it.de/
Gromhelm
Newbie
Posts: 16
Karma: 0
Re: How to best execute shell command once, after OPNsense have reboot?
«
Reply #5 on:
May 07, 2023, 07:36:58 am »
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.
Logged
franco
Administrator
Hero Member
Posts: 17668
Karma: 1611
Re: How to best execute shell command once, after OPNsense have reboot?
«
Reply #6 on:
May 08, 2023, 12:13:18 pm »
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
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
General Discussion
»
How to best execute shell command once, after OPNsense have reboot?