Bug #3615
closed/etc/rc.d/*.sh start" is executed during bootup, but equivalent "stop" cmd is never issued during shutdown
0%
Description
Hi there. I apologize if this is issue has been entered in the wrong category.
There seems to be no feature to allow a user to run their rc scripts at shutdown. (non-packages). To gracefully stop a service and release it's resources back.
For example: I would like to use the 3rd method documented in this page, where an rc.d script is renamed with an ".sh" extension:
https://doc.pfsense.org/index.php/Executing_commands_at_boot_time
This seems to be processed by "/etc/rc.start_packages" - and will exec "/etc/rc.d/*.sh start" for each file found. However "/etc/rc.stop_packages" seems to have some issue. The code looks like it trys to do something similar. But the code isn't quite the same and it fails to run "/etc/rc.d/*.sh stop". Can we please fix this somehow ?
Other popular nanoBSD platforms (FreeNAS and NAS4Free) provide a GUI page where users can specify their own list of "POSTINIT" and "SHUTDOWN" scripts. It isn't hidden away or anything.
But if you guys could get pfSense to just auto-run "/etc/rc.d/*.sh stop" from your "/etc/rc.stop_packages" (in 2.2 onwards). Then that would work great for me.
Updated by Dreamcat Four over 10 years ago
Reading carefully the official FreeBSD manages, the behaviour of this feature is ambiguous.
If you `man rc`, where it says:
Operation of rc.shutdown
4. Call each script in turn using run_rc_script() (from rc.subr(8)),
which sets $1 to ``stop'', and sources the script in a subshell. If
the script has a .sh suffix then it is sourced directly into the
current shell.
I don't recommend anyone should be using it. Because it is ambiguous whether sourcing on shutdown with or without "$1" ("stop") argument parameter. I have already seen other people on pfSense forums using these .sh scripts at startup, perhaps disregarding the start function entirely.
Instead of polluting the existing rc.d folder for such customisations, those who can't make a proper package would be better of creating the file "/etc/rc.custom_boot_early". If found, will be executed during boot up. For multiple script, people can reference them now-by-line in there.
For stopping services, you (ESF) will need to submit a pull request for a similar (counterpart) shutdown hook. I'll raise a new separate issue for that.
Updated by Dreamcat Four over 10 years ago
Sorry Apologies for any confusion. I meant to say: "take my pull request for shutdown hook" (not submit your own one!)
Updated by Dreamcat Four over 10 years ago
Issue may be solved by a new issue:
https://redmine.pfsense.org/issues/3667
Please close this one, or mark as duplicate.
Updated by Renato Botelho over 10 years ago
- Status changed from New to Closed
Closing by submitter request