summaryrefslogtreecommitdiff
path: root/sh/runscript.sh.in
diff options
context:
space:
mode:
authorChristian Ruppert <idl0r@gentoo.org>2012-09-22 16:57:46 +0200
committerChristian Ruppert <idl0r@gentoo.org>2012-09-22 16:57:46 +0200
commit0406c6085bb25ace04c7880f860219ebfc67a16f (patch)
treed143eed140286b3793446a31a181c9053e812f1c /sh/runscript.sh.in
parent0a132cdca508db86a62452dec081b316db880485 (diff)
downloadopenrc-0406c6085bb25ace04c7880f860219ebfc67a16f.tar.gz
openrc-0406c6085bb25ace04c7880f860219ebfc67a16f.tar.bz2
openrc-0406c6085bb25ace04c7880f860219ebfc67a16f.tar.xz
Add restart_pre/restart_post support, also document RC_CMD
Diffstat (limited to 'sh/runscript.sh.in')
-rw-r--r--sh/runscript.sh.in22
1 files changed, 22 insertions, 0 deletions
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 6ad2ded..3b9a72d 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -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