From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RR3dL-0004M0-Va for garchives@archives.gentoo.org; Thu, 17 Nov 2011 15:12:14 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A13BC21C06E; Thu, 17 Nov 2011 15:12:02 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5902D21C06E for ; Thu, 17 Nov 2011 15:12:02 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BC56A1B4011 for ; Thu, 17 Nov 2011 15:12:01 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id D222B80042 for ; Thu, 17 Nov 2011 15:12:00 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc.WilliamH@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: src/librc/, man/, sh/ X-VCS-Repository: proj/openrc X-VCS-Files: man/runscript.8 sh/runscript.sh.in src/librc/librc.c X-VCS-Directories: src/librc/ man/ sh/ X-VCS-Committer: WilliamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc Date: Thu, 17 Nov 2011 15:12:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 89945da4-1e52-457a-a038-fb837f1612e5 X-Archives-Hash: bed18a211d9a4ee7f80475a2589c0933 commit: 5b1aaf8cc803e9f21f8a0c94236ab5dddba4b2fc Author: William Hubbs gentoo org> AuthorDate: Mon Oct 17 18:47:45 2011 +0000 Commit: William Hubbs gentoo org> CommitDate: Wed Nov 16 19:56:55 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D5b1aaf8c add support for extra_stopped_commands --- man/runscript.8 | 3 +++ sh/runscript.sh.in | 17 ++++++++++++++--- src/librc/librc.c | 4 +++- 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 defi= nes. .It Ar extra_started_commands Space separated list of extra commands the service defines. These only w= ork if the service has already been started. +.It Ar extra_stopped_commands +Space separated list of extra commands the service defines. These only w= ork 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 =20 local svc=3D desc=3D - 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=3D\$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_stop= ped_commands." fi =20 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" =3D "$1" ]; then if [ "$(command -v "$1")" =3D "$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" =3D "$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")" =3D "$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) =20 -#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands" +#define OPTSTR \ +". '%s'; echo $extra_commands $extra_started_commands $extra_stopped_com= mands" + RC_STRINGLIST * rc_service_extra_commands(const char *service) {