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 <gentoo-commits+bounces-417256-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1RmEdB-0008JZ-H0
	for garchives@archives.gentoo.org; Sun, 15 Jan 2012 01:11:33 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 3006AE0638;
	Sun, 15 Jan 2012 01:11:23 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id E8F49E0638
	for <gentoo-commits@lists.gentoo.org>; Sun, 15 Jan 2012 01:11:22 +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 672291B4010
	for <gentoo-commits@lists.gentoo.org>; Sun, 15 Jan 2012 01:11:22 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id C743180044
	for <gentoo-commits@lists.gentoo.org>; Sun, 15 Jan 2012 01:11:21 +0000 (UTC)
From: "Christian Ruppert" <idl0r@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Christian Ruppert" <idl0r@gentoo.org>
Message-ID: <30a56cdb4680f90e6c371c75c27c6ecec2d7aeec.idl0r@gentoo>
Subject: [gentoo-commits] proj/openrc:master commit in: man/, src/rc/
X-VCS-Repository: proj/openrc
X-VCS-Files: man/runscript.8 src/rc/runscript.c
X-VCS-Directories: man/ src/rc/
X-VCS-Committer: idl0r
X-VCS-Committer-Name: Christian Ruppert
X-VCS-Revision: 30a56cdb4680f90e6c371c75c27c6ecec2d7aeec
Date: Sun, 15 Jan 2012 01:11:21 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 7d5bba0d-48c1-4f95-9fb2-35f0a43b0f80
X-Archives-Hash: bbc72c03376868dfaeac41e1192e6f6b

commit:     30a56cdb4680f90e6c371c75c27c6ecec2d7aeec
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 15 01:10:35 2012 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 01:10:35 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D=
commit;h=3D30a56cdb

Add "ifstopped" command to runscript

Signed-off-by: Christian Ruppert <idl0r <AT> gentoo.org>

---
 man/runscript.8    |    3 +++
 src/rc/runscript.c |    8 +++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index 6ad6031..dbc0b7d 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -32,6 +32,7 @@
 .Op Fl D , -nodeps
 .Op Fl d , -debug
 .Op Fl s , -ifstarted
+.Op Fl S , -ifstopped
 .Op Fl Z , -dry-run
 .Op Ar command ...
 .Sh DESCRIPTION
@@ -76,6 +77,8 @@ Set xtrace on in the shell to assist in debugging.
 Ignore all dependency information the service supplies.
 .It Fl s , -ifstarted
 Only run the command if the service has been started.
+.It Fl S , -ifstopped
+Only run the command if the service has been stopped.
 .It Fl q , -quiet
 Turns off all informational output the service generates.
 Output from any non OpenRC commands is not affected.

diff --git a/src/rc/runscript.c b/src/rc/runscript.c
index 2f66971..8e0ced9 100644
--- a/src/rc/runscript.c
+++ b/src/rc/runscript.c
@@ -1079,12 +1079,13 @@ service_plugable(void)
 }
=20
 #include "_usage.h"
-#define getoptstring "dDsvl:Z" getoptstring_COMMON
+#define getoptstring "dDsSvl:Z" getoptstring_COMMON
 #define extraopts "stop | start | restart | describe | zap"
 static const struct option longopts[] =3D {
 	{ "debug",      0, NULL, 'd'},
 	{ "dry-run",    0, NULL, 'Z'},
 	{ "ifstarted",  0, NULL, 's'},
+	{ "ifstopped",  0, NULL, 'S'},
 	{ "nodeps",     0, NULL, 'D'},
 	{ "lockfd",     1, NULL, 'l'},
 	longopts_COMMON
@@ -1093,6 +1094,7 @@ static const char *const longopts_help[] =3D {
 	"set xtrace when running the script",
 	"show what would be done",
 	"only run commands when started",
+	"only run commands when stopped",
 	"ignore dependencies",
 	"fd of the exclusive lock from rc",
 	longopts_help_COMMON
@@ -1235,6 +1237,10 @@ runscript(int argc, char **argv)
 			if (!(rc_service_state(service) & RC_SERVICE_STARTED))
 				exit(EXIT_FAILURE);
 			break;
+		case 'S':
+			if (!(rc_service_state(service) & RC_SERVICE_STOPPED))
+				exit(EXIT_FAILURE);
+			break;
 		case 'D':
 			deps =3D false;
 			break;