2018-01-30 10:40:13 +00:00
========================
Bootup / autorun options
========================
-------
syshook
-------
2018-06-23 17:28:36 +00:00
OPNsense offers an easy method to plug in custom scripts during boot stages and assorted system events.
2018-01-30 10:40:13 +00:00
2018-06-23 17:28:36 +00:00
Syshook scripts should be installed in:
2018-01-30 10:40:13 +00:00
::
2018-06-23 17:28:36 +00:00
/usr/local/etc/rc.syshook.d/<subdir>/
2018-01-30 10:40:13 +00:00
2018-06-23 17:28:36 +00:00
They can contain any executable file (e.g. shell scripts) in the following subdirectories:
2018-01-30 10:40:13 +00:00
2018-06-23 17:28:36 +00:00
- backup
2019-08-19 09:40:22 +00:00
- scripts used for periodic backup and restore
2018-06-23 17:28:36 +00:00
- carp
- scripts used for CARP MASTER / BACKUP events
2018-01-30 10:40:13 +00:00
- early
2018-06-23 17:28:36 +00:00
- start script before system network startup
2019-04-29 11:57:09 +00:00
- monitor
- scripts handling gateway monitoring events
2018-06-23 17:28:36 +00:00
- start
- start script after system network startup
- stop
- stop script before normal system shutdown
2019-07-08 15:27:37 +00:00
- update
- update script after core package update
2018-06-23 17:28:36 +00:00
File names can use a number prefix "XX-" to retain a particular order. "20-" is typically used for core scripts, while "50-" is used for plugins.
2018-01-30 10:40:13 +00:00
2018-06-23 17:28:36 +00:00
Example (vmware guestd start, filename /usr/local/etc/rc.syshook.d/early/50-vmware)
2018-01-30 10:40:13 +00:00
::
#!/bin/sh
export vmware_guest_vmblock_enable="YES"
export vmware_guest_vmhgfs_enable="YES"
export vmware_guest_vmmemctl_enable="YES"
export vmware_guest_vmxnet_enable="YES"
/usr/local/etc/rc.d/vmware-kmod start
2018-06-23 17:28:36 +00:00
Do not forget to set executable permissions on your syshook files.
2018-01-30 10:40:13 +00:00
-----
rc(8)
-----
Part of the bootup process of OPNsense is probing the available rc(8) configuration files in */etc/rc.conf.d/* , when a daemon is enabled, the system will call the regular rc(8) start command.
In case the daemon needs some extra preparation, an additional "bootup" script can be provided, which will be run before executing normal "start".
Example (from a configured squid proxy server using */etc/rc.conf.d/squid* ):
::
squid_enable=YES
squid_opnsense_bootup_run="/usr/local/opnsense/scripts/proxy/setup.sh"
The configd template system can be used to generate the necessary configuration file(s).