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

Run script on shutdown

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 2.1k 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.
  • Z
    Zorac
    last edited by Feb 23, 2013, 3:38 PM

    ive created a package, but need a script to run on shutdown.

    right now i have a package.sh file in /usr/local/etc/rc.d/ which runs fine on startup (with start), but the stop function doesn't run on shutdown(ie /usr/local/etc/rc.d/package.sh stop).  my package name matches the sh file name, and i have tried the <rcfile>tags in the config for the package, as well as a number of other combinations.  google and site search give me some direction, but i still can't get it to work.  any suggestions would be appreciated.

    thanks.</rcfile>

    1 Reply Last reply Reply Quote 0
    • P
      phil.davis
      last edited by Feb 23, 2013, 4:36 PM Feb 23, 2013, 4:34 PM

      pkg-utils.inc stop_packages() loops through each package name and calls stop_service for that package
      (assuming the package name and service name are the same - on 2.1 you can specify an internal name for a package if the package name does not match the service name - e.g squid3 internal name is squid)
      It remembers which services it has already stopped. For those, it does not call a matching *.sh file later - e.g. /usr/local/etc/rc.d/squid.sh will not get called, because stop_service("squid") has already been done.
      The problem comes if your "package.sh stop" code needs to do more than what stop_service() already did - perhaps save some data, kill some other processes… With the current package system, you need to make another script with a different name "/usr/local/etc/rc.d/package-extras.sh" that takes the "start" and "stop" parameters and does any extra stuff at startup and shutdown - e.g. look in squid3 (squid-reverse in GitHub) squid.inc for sqp_monitor.sh

      As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
      If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

      1 Reply Last reply Reply Quote 0
      • Z
        Zorac
        last edited by Feb 23, 2013, 5:35 PM

        thanks, that put me in the right direction.

        1 Reply Last reply Reply Quote 0
        3 out of 3
        • First post
          3/3
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
          This community forum collects and processes your personal information.
          consent.not_received