public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Christian Ruppert" <idl0r@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: man/, sh/
Date: Sat, 22 Sep 2012 14:58:26 +0000 (UTC)	[thread overview]
Message-ID: <1348325866.0406c6085bb25ace04c7880f860219ebfc67a16f.idl0r@OpenRC> (raw)

commit:     0406c6085bb25ace04c7880f860219ebfc67a16f
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 22 14:57:46 2012 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Sep 22 14:57:46 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0406c608

Add restart_pre/restart_post support, also document RC_CMD

---
 man/runscript.8    |    8 ++++++++
 sh/runscript.sh.in |   22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index b87f8ef..d823e33 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -357,6 +357,9 @@ In a Gentoo Prefix installation, this variable contains the prefix
 offset. Otherwise it is undefined.
 .It Va RC_UNAME
 The result of `uname -s`.
+.It Va RC_CMD
+Name of the command like start, stop, restart, ...
+RC_CMD is one way to determine whether it's a restart or normal start/stop.
 .El
 .Sh FILES
 .Pp
@@ -444,6 +447,11 @@ depend()
     need ${_need}
 }
 
+restart_pre() {
+	# Verify a config and abort the restart in case it's not valid
+	...
+}
+
 start_pre()
 {
     # Ensure that our dirs are correct

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


             reply	other threads:[~2012-09-22 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-22 14:58 Christian Ruppert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-09-16 19:27 [gentoo-commits] proj/openrc:master commit in: man/, sh/ William Hubbs
2012-09-25 15:35 William Hubbs
2012-03-03 15:24 William Hubbs
2012-01-17 17:26 Christian Ruppert
2011-12-31  1:42 Christian Ruppert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348325866.0406c6085bb25ace04c7880f860219ebfc67a16f.idl0r@OpenRC \
    --to=idl0r@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox