summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2011-10-17 13:47:45 -0500
committerWilliam Hubbs <williamh@gentoo.org>2011-11-16 13:56:55 -0600
commit5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc (patch)
tree4ef1037e3bad3f69409720e26342f31c064a3d39
parent5994e55937cbbb71b1c22ad829b77a1bcd8c3793 (diff)
downloadopenrc-5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc.tar.gz
openrc-5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc.tar.bz2
openrc-5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc.tar.xz
add support for extra_stopped_commands
-rw-r--r--man/runscript.83
-rw-r--r--sh/runscript.sh.in17
-rw-r--r--src/librc/librc.c4
3 files changed, 20 insertions, 4 deletions
diff --git a/man/runscript.8 b/man/runscript.8
index bf06d7b..b28bec2 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -93,6 +93,9 @@ Space separated list of extra commands the service defines.
.It Ar extra_started_commands
Space separated list of extra commands the service defines. These only work if
the service has already been started.
+.It Ar extra_stopped_commands
+Space separated list of extra commands the service defines. These only work if
+the service has already been stopped.
.It Ar description
String describing the service.
.It Ar description_$command
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 010c794..f86a510 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -98,7 +98,8 @@ describe()
fi
local svc= desc=
- for svc in ${extra_commands:-$opts} $extra_started_commands; do
+ for svc in ${extra_commands:-$opts} $extra_started_commands \
+ $extra_stopped_commands; do
eval desc=\$description_$svc
if [ -n "$desc" ]; then
einfo "$HILITE$svc$NORMAL: $desc"
@@ -213,7 +214,7 @@ unset _f
if [ -n "$opts" ]; then
ewarn "Use of the opts variable is deprecated and will be"
ewarn "removed in the future."
- ewarn "Please use extra_commands or extra_started_commands."
+ ewarn "Please use extra_commands, extra_started_commands or extra_stopped_commands."
fi
while [ -n "$1" ]; do
@@ -225,7 +226,7 @@ while [ -n "$1" ]; do
fi
# See if we have the required function and run it
for _cmd in describe start stop status ${extra_commands:-$opts} \
- $extra_started_commands
+ $extra_started_commands $extra_stopped_commands
do
if [ "$_cmd" = "$1" ]; then
if [ "$(command -v "$1")" = "$1" ]; then
@@ -253,6 +254,16 @@ while [ -n "$1" ]; do
fi
fi
done
+ # Check to see if we need to be stopped before
+ # we can run this command
+ for _cmd in $extra_stopped_commands; do
+ if [ "$_cmd" = "$1" ]; then
+ if ! service_stopped; then
+ eerror "$RC_SVCNAME: cannot \`$1' as it has not been stopped"
+ exit 1
+ fi
+ fi
+ done
unset _cmd
if [ "$(command -v "$1_pre")" = "$1_pre" ]
then
diff --git a/src/librc/librc.c b/src/librc/librc.c
index c66c944..13c1973 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -526,7 +526,9 @@ rc_service_exists(const char *service)
}
librc_hidden_def(rc_service_exists)
-#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands"
+#define OPTSTR \
+". '%s'; echo $extra_commands $extra_started_commands $extra_stopped_commands"
+
RC_STRINGLIST *
rc_service_extra_commands(const char *service)
{