Skip to content

rc: add ${name}_pre_start, ${name}_post_stop script support#2186

Open
rozhuk-im wants to merge 1 commit into
freebsd:mainfrom
rozhuk-im:add_rcsubr_hooks
Open

rc: add ${name}_pre_start, ${name}_post_stop script support#2186
rozhuk-im wants to merge 1 commit into
freebsd:mainfrom
rozhuk-im:add_rcsubr_hooks

Conversation

@rozhuk-im
Copy link
Copy Markdown
Contributor

@rozhuk-im rozhuk-im commented May 11, 2026

Run a service-based pre_start running after setup but before start_precmd and post_stop script running after stop_postcmd.

Useful for automatic environment/chroot generation and cleanup.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

Thank you for taking the time to contribute to FreeBSD!

Some of files have special handling:

Important

@concussious wants to review changes to share/man/

@rozhuk-im rozhuk-im force-pushed the add_rcsubr_hooks branch 3 times, most recently from 737e6ca to d0757a6 Compare May 11, 2026 16:30
Run a service-based pre_start running after setup but before start_precmd
and post_stop script running after stop_postcmd.

Useful for automatic environment/chroot generation and cleanup.

Signed-off-by: Rozhuk Ivan <rozhuk.im@gmail.com>
@concussious
Copy link
Copy Markdown
Contributor

Hi! So, what's wrong with precmd and postcmd?

@rozhuk-im
Copy link
Copy Markdown
Contributor Author

rozhuk-im commented May 12, 2026

It is ok, but it is hard to use it to call scripts from rc.conf:

prosody_enable="YES"
prosody_user="prosody"
prosody_group="prosody"
prosody_pidfile="/var/run/prosody.pid"
if [ 'prosody' == "${name}" ]; then
	start_precmd="/usr/local/etc/rc.d/nginx stop"
	start_postcmd="/usr/local/etc/rc.d/nginx start"
fi

It will work only if port does not use it inside rc.d script.

Same time after patch it is able to write:

turnserver_chroot="/var/run/chroot-turnserver/"
turnserver_pre_start="/root/bin/chroots/turnserver.sh start"
turnserver_post_stop="/root/bin/chroots/turnserver.sh stop"

where turnserver.sh create/destroy chroot env.

turnserver_setup is designed to generate configs and no good way use it for same kind purposes.

As administrator of services I want to able to run some code before start and after stop service, this can have many use cases to customize logic outside port, on system level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants