Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Proper way to run script on pfSense shutdown?

    Scheduled Pinned Locked Moved General pfSense Questions
    3 Posts 2 Posters 518 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tomashk
      last edited by

      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 :)

      1 Reply Last reply Reply Quote 0
      • T
        tomashk
        last edited by

        So it looks I have to learn how to build rc.d scripts :)

        J 1 Reply Last reply Reply Quote 0
        • J
          jmedin1965 @tomashk
          last edited by

          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.

          1 Reply Last reply Reply Quote 2
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.