Run script on shutdown
-
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>
-
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 -
thanks, that put me in the right direction.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginPrivacy Policy · Cookie Policy