Proper way to run script on pfSense shutdown?
-
Hi,
I'd like to run short script when pfSense is shutting down. Unfortunately there is no option for that in Shellcmd. I believe that it is possible by adding my own rc.d script, but there are some disadvantages with this aproach:- it won't be saved in pfSense configuration (like Shellcmd is)
- I'd have to learn how to properly build rc.d shutdown script ;)
- I don't know if pfSense introduces changes to rc.d behavior
I'd be grateful for information if there is pfSense option that would let me do this. If not then maybe there is something easier than rc.d scripts. Mentioned script is supposed to run just one line:
ssh pi@raspberry_pi_ip './script_to_be_run'
With authorized_keys set it runs without problems, but now I have to find place to put it in :)
-
So it looks I have to learn how to build rc.d scripts :)
-
Hi,
I was looking for the same thing and found that there is a "/etc/pfSense-rc.shutdown" script. At the bottom it runs all executable scripts in "/usr/local/etc/rc.d/shutdown.*.sh". So I'm guessing that creating such a script will achieve what we are both looking for. The catch now would be to guarantee that the creation of such a script will survive an update. I would guess yes. What it won't survive is a reinstall.The filer package addon can be used to create this script and also sync it in a ha cluster.