From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2EEC41392EF for ; Wed, 9 Jul 2014 20:39:25 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC1FDE08E0; Wed, 9 Jul 2014 20:39:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 74741E08E0 for ; Wed, 9 Jul 2014 20:39:23 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3B08333FDE1 for ; Wed, 9 Jul 2014 20:39:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 0011B18011 for ; Wed, 9 Jul 2014 20:39:20 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1404583950.c1de8c09bf4895c6108d297fcebd63046e49e614.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: init.d/ X-VCS-Repository: proj/openrc X-VCS-Files: init.d/local.in X-VCS-Directories: init.d/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: c1de8c09bf4895c6108d297fcebd63046e49e614 X-VCS-Branch: master Date: Wed, 9 Jul 2014 20:39:20 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 2307d8a5-db4e-4fdf-b793-671daa9557b0 X-Archives-Hash: 54057ddb06c0af96eee6b2e4132c4679 commit: c1de8c09bf4895c6108d297fcebd63046e49e614 Author: Thomas D whissi de> AuthorDate: Tue Jun 10 13:23:17 2014 +0000 Commit: William Hubbs gentoo org> CommitDate: Sat Jul 5 18:12:30 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=c1de8c09 Add support for verbose "local" service runscript With this patch, the "local" service runscript will be verbose like the "sysctl" service when 'rc_verbose="yes"' is set. Example output successful start: * Stopping local ... * Executing "/etc/local.d/00will-stop.stop" ... [ ok ] * Starting local ... * Executing "/etc/local.d/00will-start.start" ... [ ok ] * Executing "/etc/local.d/01 test.start" ... [ ok ] Example output with failing executables: * Stopping local ... * Executing "/etc/local.d/00will-stop.stop" ... [ ok ] * Executing "/etc/local.d/will-fail.stop" ... mount: can't find foo in /etc/fstab * Execution of "/etc/local.d/will-fail.stop" failed. [ !! ] * Starting local ... * Executing "/etc/local.d/00will-start.start" ... [ ok ] * Executing "/etc/local.d/01 test.start" ... [ ok ] * Executing "/etc/local.d/will-fail2.start" ... mount: can't find bar in /etc/fstab * Execution of "/etc/local.d/will-fail2.start" failed. [ !! ] * Executing "/etc/local.d/will-fail.start" ... mount: can't find foo in /etc/fstab * Execution of "/etc/local.d/will-fail.start" failed. [ !! ] X-Gentoo-Bug: 489274 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=489274 --- init.d/local.in | 73 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/init.d/local.in b/init.d/local.in index 2f20568..06be25f 100644 --- a/init.d/local.in +++ b/init.d/local.in @@ -12,40 +12,83 @@ depend() start() { - einfo "Starting local" + ebegin "Starting local" - local file - for file in @SYSCONFDIR@/local.d/*.start ; do - [ -x "$file" ] && "$file" + local file has_errors retval + eindent + for file in @SYSCONFDIR@/local.d/*.start; do + if [ -x "${file}" ]; then + has_executables=1 + vebegin "Executing \"${file}\"" + "${file}" 2>&1 >/dev/null + retval=$? + if [ ${retval} -ne 0 ]; then + has_errors=1 + ewend ${retval} "Execution of \"${file}\" failed." + else + vewend 0 + fi + fi done + eoutdent if command -v local_start >/dev/null 2>&1; then - ewarn "@SYSCONFDIR@/conf.d/local should be removed." + ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed." ewarn "Please move the code from the local_start function" - ewarn "to scripts with an .start extension" - ewarn "in @SYSCONFDIR@/local.d" + ewarn "to executable scripts with an .start extension" + ewarn "in \"@SYSCONFDIR@/local.d\"" local_start fi - eend 0 + if [ -z "${has_errors}" ]; then + eend 0 + fi + + # We have to end with a zero exit code, because a failed execution + # of an executable @SYSCONFDIR@/local.d/*.start file shouldn't result in + # marking the local service as failed. Otherwise we are unable to + # execute any executable @SYSCONFDIR@/local.d/*.stop file, because a failed + # marked service cannot be stopped (and the stop function would + # actually call the executable @SYSCONFDIR@/local.d/*.stop file(s)). + return 0 } stop() { - einfo "Stopping local" + ebegin "Stopping local" - local file + local file has_errors retval + eindent for file in @SYSCONFDIR@/local.d/*.stop; do - [ -x "$file" ] && "$file" + if [ -x "${file}" ]; then + has_executables=1 + vebegin "Executing \"${file}\"" + "${file}" 2>&1 >/dev/null + retval=$? + if [ ${retval} -ne 0 ]; then + has_errors=1 + ewend ${retval} "Execution of \"${file}\" failed." + else + vewend 0 + fi + fi done + eoutdent if command -v local_stop >/dev/null 2>&1; then - ewarn "@SYSCONFDIR@/conf.d/local should be removed." + ewarn "\"@SYSCONFDIR@/conf.d/local\" should be removed." ewarn "Please move the code from the local_stop function" - ewarn "to scripts with an .stop extension" - ewarn "in @SYSCONFDIR@/local.d" + ewarn "to executable scripts with an .stop extension" + ewarn "in \"@SYSCONFDIR@/local.d\"" local_stop fi - eend 0 + if [ -z "${has_errors}" ]; then + eend 0 + fi + + # An executable @SYSCONFDIR@/local.d/*.stop file which failed with a + # non-zero exit status is not a reason to mark this service + # as failed, therefore we have to end with a zero exit code. + return 0 }