mirror of
https://github.com/OpenRC/openrc.git
synced 2024-11-23 18:03:51 +08:00
Add restart_pre/restart_post support, also document RC_CMD
This commit is contained in:
parent
0a132cdca5
commit
0406c6085b
@ -357,6 +357,9 @@ In a Gentoo Prefix installation, this variable contains the prefix
|
||||
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.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Pp
|
||||
@ -444,6 +447,11 @@ depend()
|
||||
need ${_need}
|
||||
}
|
||||
|
||||
restart_pre() {
|
||||
# Verify a config and abort the restart in case it's not valid
|
||||
...
|
||||
}
|
||||
|
||||
start_pre()
|
||||
{
|
||||
# Ensure that our dirs are correct
|
||||
|
@ -285,15 +285,37 @@ while [ -n "$1" ]; do
|
||||
case $1 in
|
||||
start|stop|status) verify_boot;;
|
||||
esac
|
||||
|
||||
# FIXME: We may want to skip the start/stop _pre functions later
|
||||
# restart_pre
|
||||
if [ "${RC_CMD}" = "restart" ]; then
|
||||
if [ "${1}" = "stop" -a "$(command -v "restart_pre")" = "restart_pre" ]; then
|
||||
restart_pre || exit $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Execute _pre functions
|
||||
if [ "$(command -v "$1_pre")" = "$1_pre" ]
|
||||
then
|
||||
"$1"_pre || exit $?
|
||||
fi
|
||||
|
||||
# Execute the actual command/function, start, stop, ...
|
||||
"$1" || exit $?
|
||||
|
||||
# restart_post
|
||||
if [ "${RC_CMD}" = "restart" ]; then
|
||||
if [ "${1}" = "start" -a "$(command -v "restart_post")" = "restart_post" ]; then
|
||||
restart_post || exit $?
|
||||
fi
|
||||
fi
|
||||
|
||||
# Execute the _post functions
|
||||
if [ "$(command -v "$1_post")" = "$1_post" ]
|
||||
then
|
||||
"$1"_post || exit $?
|
||||
fi
|
||||
|
||||
shift
|
||||
continue 2
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user