OPNsense Forum

Archive => 18.1 Legacy Series => Topic started by: sandro87 on September 11, 2018, 12:30:50 pm

Title: How to add custom commands at boot via rc or crontab
Post by: sandro87 on September 11, 2018, 12:30:50 pm
Hello,
I'm trying to add custom commands at boot (this is not a service or daemon!) to run at every boot, it just needs to cd to a directory and rename a file. nothing else.
I tried to follow the freeBSD documentation which says to put the .sh file containing the command in /usr/local/etc/rc.d/ which is completey ignored it seems, even if I enable rc_debug it logs nothing.
If I change the crontab using @reboot it's deleted by opnsense at every boot.

What should I do?
Title: Re: How to add custom commands at boot via rc or crontab
Post by: franco on September 12, 2018, 03:06:14 pm
Take a look at these docs:

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


Cheers,
Franco
Title: Re: How to add custom commands at boot via rc or crontab
Post by: sandro87 on September 12, 2018, 03:40:53 pm
Take a look at these docs:

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


Cheers,
Franco

Hello,
thanks! The first solution looks like the one I'm looking for.
Just two things:
1) the docs show a directory system like "/usr/local/etc/rc.syshook.d/early/50-yourscript"
On my build I don't have any subdirectory, just files like 20-freebsd.start . Is it because I'm using and old version (18.1)?
2) I tried both version anyway and nothing seems to work, maybe I'm missing something. Is there a way to debug this?

My script is a simple test like this

Code: [Select]
#!/bin/bash

touch /home/hotspotuser/testfile

I don't see why it shouldn't work
Title: Re: How to add custom commands at boot via rc or crontab
Post by: sandro87 on September 12, 2018, 04:23:15 pm
Nevermind, the 50-myscript.start worked!  :D
Title: Re: How to add custom commands at boot via rc or crontab
Post by: franco on September 12, 2018, 04:25:55 pm
Hi sandro87,

You are using a version < 18.7 I think. The docs reflect the reality in 18.7, but scripts are automatically migrated on update so it'll keep working.


Cheers,
Franco