Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: src/librc/, man/, sh/
Date: Thu, 17 Nov 2011 15:12:14
Message-Id: 5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc.WilliamH@gentoo
1 commit: 5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc
2 Author: William Hubbs <williamh <AT> gentoo <DOT> org>
3 AuthorDate: Mon Oct 17 18:47:45 2011 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 16 19:56:55 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=5b1aaf8c
7
8 add support for extra_stopped_commands
9
10 ---
11 man/runscript.8 | 3 +++
12 sh/runscript.sh.in | 17 ++++++++++++++---
13 src/librc/librc.c | 4 +++-
14 3 files changed, 20 insertions(+), 4 deletions(-)
15
16 diff --git a/man/runscript.8 b/man/runscript.8
17 index bf06d7b..b28bec2 100644
18 --- a/man/runscript.8
19 +++ b/man/runscript.8
20 @@ -93,6 +93,9 @@ Space separated list of extra commands the service defines.
21 .It Ar extra_started_commands
22 Space separated list of extra commands the service defines. These only work if
23 the service has already been started.
24 +.It Ar extra_stopped_commands
25 +Space separated list of extra commands the service defines. These only work if
26 +the service has already been stopped.
27 .It Ar description
28 String describing the service.
29 .It Ar description_$command
30
31 diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
32 index 010c794..f86a510 100644
33 --- a/sh/runscript.sh.in
34 +++ b/sh/runscript.sh.in
35 @@ -98,7 +98,8 @@ describe()
36 fi
37
38 local svc= desc=
39 - for svc in ${extra_commands:-$opts} $extra_started_commands; do
40 + for svc in ${extra_commands:-$opts} $extra_started_commands \
41 + $extra_stopped_commands; do
42 eval desc=\$description_$svc
43 if [ -n "$desc" ]; then
44 einfo "$HILITE$svc$NORMAL: $desc"
45 @@ -213,7 +214,7 @@ unset _f
46 if [ -n "$opts" ]; then
47 ewarn "Use of the opts variable is deprecated and will be"
48 ewarn "removed in the future."
49 - ewarn "Please use extra_commands or extra_started_commands."
50 + ewarn "Please use extra_commands, extra_started_commands or extra_stopped_commands."
51 fi
52
53 while [ -n "$1" ]; do
54 @@ -225,7 +226,7 @@ while [ -n "$1" ]; do
55 fi
56 # See if we have the required function and run it
57 for _cmd in describe start stop status ${extra_commands:-$opts} \
58 - $extra_started_commands
59 + $extra_started_commands $extra_stopped_commands
60 do
61 if [ "$_cmd" = "$1" ]; then
62 if [ "$(command -v "$1")" = "$1" ]; then
63 @@ -253,6 +254,16 @@ while [ -n "$1" ]; do
64 fi
65 fi
66 done
67 + # Check to see if we need to be stopped before
68 + # we can run this command
69 + for _cmd in $extra_stopped_commands; do
70 + if [ "$_cmd" = "$1" ]; then
71 + if ! service_stopped; then
72 + eerror "$RC_SVCNAME: cannot \`$1' as it has not been stopped"
73 + exit 1
74 + fi
75 + fi
76 + done
77 unset _cmd
78 if [ "$(command -v "$1_pre")" = "$1_pre" ]
79 then
80
81 diff --git a/src/librc/librc.c b/src/librc/librc.c
82 index c66c944..13c1973 100644
83 --- a/src/librc/librc.c
84 +++ b/src/librc/librc.c
85 @@ -526,7 +526,9 @@ rc_service_exists(const char *service)
86 }
87 librc_hidden_def(rc_service_exists)
88
89 -#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands"
90 +#define OPTSTR \
91 +". '%s'; echo $extra_commands $extra_started_commands $extra_stopped_commands"
92 +
93 RC_STRINGLIST *
94 rc_service_extra_commands(const char *service)
95 {