public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/openrc:master commit in: man/, sh/
@ 2012-01-17 17:26 Christian Ruppert
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2012-01-17 17:26 UTC (permalink / raw
  To: gentoo-commits

commit:     9c0edc5c527de01cbe2dccbc7f1a2c571b6acc41
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 17 17:23:56 2012 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 17:25:44 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9c0edc5c

Use the "--make-pidfile" when command_background is used

The start-stop-daemon "--make-pidfile" option is now used by default when using
command_background, this requires a pidfile to be specified.
Document command_background option.

Reported-by: Giampaolo Tomassoni <giampaolo <AT> tomassoni.biz>
X-Gentoo-Bug: 399165
X-Gentoo-Bug-URL: https://bugs.gentoo.org/399165

---
 man/runscript.8    |    5 +++++
 sh/runscript.sh.in |    6 +++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index dbc0b7d..dd934c4 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -111,6 +111,11 @@ Daemon to start or stop via
 if no start or stop function is defined by the service.
 .It Ar command_args
 List of arguments to pass to the daemon when starting.
+.It Ar command_background
+Set this to "true", "yes" or "1" (case-insensitive) to force the daemon into
+the background. This implies the "--make-pidfile" and "--pidfile" option of
+.Xr start-stop-daemon 8
+so the pidfile variable must be set.
 .It Ar pidfile
 Pidfile to use for the above defined command.
 .It Ar name

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 470f04c..e042be6 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -124,7 +124,11 @@ start()
 	local _background=
 	ebegin "Starting ${name:-$RC_SVCNAME}"
 	if yesno "${command_background}"; then
-		_background="--background --pidfile"
+		if [ -z "${pidfile}" ]; then
+			eend 1 "command_background option used but no pidfile specified"
+			return 1
+		fi
+		_background="--background --make-pidfile --pidfile"
 	fi
 	if yesno "$start_inactive"; then
 		local _inactive=false



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, sh/
@ 2016-09-16 19:27 William Hubbs
  0 siblings, 0 replies; 6+ messages in thread
From: William Hubbs @ 2016-09-16 19:27 UTC (permalink / raw
  To: gentoo-commits

commit:     c146b966913ae80652e3be925d3aba60ed82f14d
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Fri Sep 16 19:23:09 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Sep 16 19:23:09 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=c146b966

Add command_progress variable

If this is set to yes, 1, true, or on, start-stop-daemon will display a
progress meter while waiting for a daemon to stop.

 man/openrc-run.8        | 4 ++++
 sh/start-stop-daemon.sh | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/man/openrc-run.8 b/man/openrc-run.8
index 6e3b9dc..5ec8156 100644
--- a/man/openrc-run.8
+++ b/man/openrc-run.8
@@ -143,6 +143,10 @@ Set this to "true", "yes" or "1" (case-insensitive) if you want
 .Xr start-stop-daemon 8
 to force the daemon into the background. This forces the
 "--make-pidfile" and "--pidfile" options, so the pidfile variable must be set.
+.It Ar command_progress
+Set this to "true", "yes" or "1" (case-insensitive) if you want 
+.Xr start-stop-daemon 8
+to display a progress meter when waiting for a daemon to stop.
 .It Ar command_user
 If the daemon does not support changing to a different user id, you can
 use this to change the user id before

diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh
index 6b679ac..6f396b3 100644
--- a/sh/start-stop-daemon.sh
+++ b/sh/start-stop-daemon.sh
@@ -63,6 +63,7 @@ ssd_start()
 
 ssd_stop()
 {
+	local _progress=
 	local startcommand="$(service_get_value "command")"
 	local startchroot="$(service_get_value "chroot")"
 	local startpidfile="$(service_get_value "pidfile")"
@@ -72,13 +73,15 @@ ssd_stop()
 	pidfile="${startpidfile:-$pidfile}"
 	procname="${startprocname:-$procname}"
 	[ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
+	yesno "${command_progress}" && _progress=--progress
 	ebegin "Stopping ${name:-$RC_SVCNAME}"
 	start-stop-daemon --stop \
 		${retry:+--retry} $retry \
 		${command:+--exec} $command \
 		${procname:+--name} $procname \
 		${pidfile:+--pidfile} $chroot$pidfile \
-		${stopsig:+--signal} $stopsig
+		${stopsig:+--signal} $stopsig \
+		${_progress}
 
 	eend $? "Failed to stop ${name:-$RC_SVCNAME}"
 }


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, sh/
@ 2012-09-25 15:35 William Hubbs
  0 siblings, 0 replies; 6+ messages in thread
From: William Hubbs @ 2012-09-25 15:35 UTC (permalink / raw
  To: gentoo-commits

commit:     5615fa78d6dc4e23662a2c4130f31b8f954a8aab
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Mon Sep 24 18:53:53 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Tue Sep 25 15:22:47 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=5615fa78

Drop restart_pre/restart_post

By design, restart is hard coded to run stop followed by start along
with all of the pre/post functions associated with them. Restart doesn't
need its own pre/post functions since it is possible to make any
function in an init script behave differently for a restart command by
testing against the RC_CMD environment variable.

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

diff --git a/man/runscript.8 b/man/runscript.8
index c4119d9..471c0f1 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -447,11 +447,6 @@ depend()
     need ${_need}
 }
 
-restart_pre() {
-	# Verify a config and abort the restart in case it's not valid
-	...
-}
-
 # This function does any pre-start setup. If it fails, the service will
 # not be started.
 # If you need this function to behave differently for a restart command,

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 3b9a72d..6ad2ded 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -285,37 +285,15 @@ 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, sh/
@ 2012-09-22 14:58 Christian Ruppert
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2012-09-22 14:58 UTC (permalink / raw
  To: gentoo-commits

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, sh/
@ 2012-03-03 15:24 William Hubbs
  0 siblings, 0 replies; 6+ messages in thread
From: William Hubbs @ 2012-03-03 15:24 UTC (permalink / raw
  To: gentoo-commits

commit:     9fa54a8e8036262a7ea599d68e04fcbd8213506e
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  3 15:16:27 2012 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Mar  3 15:22:44 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9fa54a8e

Runscript: allow extra_commands to be run in chroots

The commands defined in the extra_commands variable do not depend on
whether the service is stopped or started, so it is valid to run them in
chroot environments.

Also, add a note to the runscript man page about the commands in
extra_commands being able to run whether or not the service is started.

Reported-by: Robin Johnson <robbat2 <AT> gentoo.org>
X-Gentoo-Bug: 406713
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406713

---
 man/runscript.8    |    3 ++-
 sh/runscript.sh.in |   35 +++++++++++++++++++++--------------
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index 3b037ce..64f36b1 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -92,7 +92,8 @@ or stopping them.
 The following variables affect the service script:
 .Bl -tag -width "RC_DEFAULTLEVEL"
 .It Ar extra_commands
-Space separated list of extra commands the service defines.
+Space separated list of extra commands the service defines. These should
+not depend on the service being stopped or started.
 .It Ar extra_started_commands
 Space separated list of extra commands the service defines. These only work if
 the service has already been started.

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 83db42b..15cdb86 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -4,6 +4,22 @@
 # Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
 # Released under the 2-clause BSD license.
 
+verify_boot()
+{
+	if [ ! -e ${RC_SVCDIR}/softlevel ]; then
+		eerror "You are attempting to run an openrc service on a"
+		eerror "system which openrc did not boot."
+		eerror "You may be inside a chroot or you may have used"
+		eerror "another initialization system to boot this system."
+		eerror "In this situation, you will get unpredictable results!"
+		eerror
+		eerror "If you really want to do this, issue the following command:"
+		eerror "touch ${RC_SVCDIR}/softlevel"
+		exit 1
+	fi
+	return 0
+}
+
 sourcex()
 {
 	if [ "$1" = "-e" ]; then
@@ -24,18 +40,6 @@ if sourcex -e "/sbin/livecd-functions.sh"; then
 	livecd_read_commandline
 fi
 
-if [ ! -e ${RC_SVCDIR}/softlevel ]; then
-	eerror "You are attempting to run an openrc service on a"
-	eerror "system which openrc did not boot."
-	eerror "You may be inside a chroot or you may have used"
-	eerror "another initialization system to boot this system."
-	eerror "In this situation, you will get unpredictable results!"
-	eerror
-	eerror "If you really want to do this, issue the following command:"
-	eerror "touch ${RC_SVCDIR}/softlevel"
-	exit 1
-fi
-
 if [ -z "$1" -o -z "$2" ]; then
 	eerror "$RC_SVCNAME: not enough arguments"
 	exit 1
@@ -256,7 +260,7 @@ while [ -n "$1" ]; do
 				# we can run this command
 				for _cmd in $extra_started_commands; do
 					if [ "$_cmd" = "$1" ]; then
-						if ! service_started; then
+						if verify_boot && ! service_started; then
 							eerror "$RC_SVCNAME: cannot \`$1' as it has not been started"
 							exit 1
 						fi
@@ -266,13 +270,16 @@ while [ -n "$1" ]; do
 				# we can run this command
 				for _cmd in $extra_stopped_commands; do
 					if [ "$_cmd" = "$1" ]; then
-						if ! service_stopped; then
+						if verify_boot && ! service_stopped; then
 							eerror "$RC_SVCNAME: cannot \`$1' as it has not been stopped"
 							exit 1
 						fi
 					fi
 				done
 				unset _cmd
+				case $1 in
+						start|stop|status) verify_boot;;
+				esac
 				if [ "$(command -v "$1_pre")" = "$1_pre" ]
 				then
 					"$1"_pre || exit $?



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/openrc:master commit in: man/, sh/
@ 2011-12-31  1:42 Christian Ruppert
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Ruppert @ 2011-12-31  1:42 UTC (permalink / raw
  To: gentoo-commits

commit:     fb8db18d79b4efc65c2b04a66a8e9e3b56f21f00
Author:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 31 01:41:59 2011 +0000
Commit:     Christian Ruppert <idl0r <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 01:41:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=fb8db18d

Add "retry" option for the stop() template

---
 man/runscript.8    |    5 ++++-
 sh/runscript.sh.in |    1 +
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/man/runscript.8 b/man/runscript.8
index 9439b76..77b2399 100644
--- a/man/runscript.8
+++ b/man/runscript.8
@@ -21,7 +21,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 4, 2009
+.Dd December 31, 2011
 .Dt RUNSCRIPT 8 SMM
 .Os OpenRC
 .Sh NAME
@@ -112,6 +112,9 @@ List of arguments to pass to the daemon when starting.
 Pidfile to use for the above defined command.
 .It Ar name
 Display name used for the above defined command.
+.It Ar retry
+You can either specify a timeout in seconds or a multiple signal/timeout pairs
+as a stopping schedule. This is only used during stop().
 .El
 .Sh DEPENDENCIES
 You should define a

diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index b738b89..470f04c 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -151,6 +151,7 @@ stop()
 	[ -n "$command" -o -n "$procname" -o -n "$pidfile" ] || return 0
 	ebegin "Stopping ${name:-$RC_SVCNAME}"
 	start-stop-daemon --stop \
+		${retry:+--retry} $retry \
 		${command:+--exec} $command \
 		${procname:+--name} $procname \
 		${pidfile:+--pidfile} $pidfile \



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-16 19:27 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox