Clarify how to handle restart processing

The Gentoo developer manual covers how to handle restarts in init
scripts, but this was not officially covered in OpenRc's Documentation.
This commit adds an example to the runscript man page that shows how
this works.
This commit is contained in:
William Hubbs 2012-09-23 19:25:57 -05:00
parent 20ef3439ea
commit f007988fba

View File

@ -358,8 +358,8 @@ offset. Otherwise it is undefined.
.It Va RC_UNAME
The result of `uname -s`.
.It Va RC_CMD
Name of the command like start, stop, restart, ...
RC_CMD is one way to determine whether it's a restart or normal start/stop.
This contains the name of the command the init script is executing, such
as start, stop, restart etc.
.El
.Sh FILES
.Pp
@ -452,8 +452,22 @@ restart_pre() {
...
}
# This function does any pre-start setup. If it fails, the service will
# not be started.
# If you need this function to behave differently for a restart command,
# you should check the value of RC_CMD for "restart".
# This also applies to start_post, stop_pre and stop_post.
start_pre()
{
if [ "$RC_CMD" = restart ]; then
# This block will only execute for a restart command. Use a
# structure like this if you need special processing for a
# restart which you do not need for a normal start.
# The function can also fail from here, which will mean that a
# restart can fail.
# This logic can also be used in start_post, stop_pre and
# stop_post.
fi
# Ensure that our dirs are correct
checkpath --dir --owner foo:foo --mode 0664 \\
/var/run/foo /var/cache/foo