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 5E378138010 for ; Mon, 24 Sep 2012 00:38:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0D5E721C117; Mon, 24 Sep 2012 00:37:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D674821C117 for ; Mon, 24 Sep 2012 00:37:39 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4856633D735 for ; Mon, 24 Sep 2012 00:37:39 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id F2E59E5442 for ; Mon, 24 Sep 2012 00:37:37 +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: <1348446357.f007988fbac79460f7733eb9093d2beb537311f8.WilliamH@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: man/ X-VCS-Repository: proj/openrc X-VCS-Files: man/runscript.8 X-VCS-Directories: man/ X-VCS-Committer: WilliamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: f007988fbac79460f7733eb9093d2beb537311f8 X-VCS-Branch: master Date: Mon, 24 Sep 2012 00:37:37 +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: fddb3626-294e-4694-990c-7ffca23647ff X-Archives-Hash: 3a624ac4932d91bf437dd03d67ff8588 commit: f007988fbac79460f7733eb9093d2beb537311f8 Author: William Hubbs gmail com> AuthorDate: Mon Sep 24 00:25:57 2012 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Sep 24 00:25:57 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=f007988f Clarify how to handle restart processing The Gentoo developer manual covers how to handle restarts in init scripts, but this was not officially covered in OpenRc's Documentation. This commit adds an example to the runscript man page that shows how this works. --- man/runscript.8 | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/man/runscript.8 b/man/runscript.8 index d823e33..c4119d9 100644 --- a/man/runscript.8 +++ b/man/runscript.8 @@ -358,8 +358,8 @@ 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. +This contains the name of the command the init script is executing, such +as start, stop, restart etc. .El .Sh FILES .Pp @@ -452,8 +452,22 @@ restart_pre() { ... } +# 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, +# you should check the value of RC_CMD for "restart". +# This also applies to start_post, stop_pre and stop_post. start_pre() { + if [ "$RC_CMD" = restart ]; then + # This block will only execute for a restart command. Use a + # structure like this if you need special processing for a + # restart which you do not need for a normal start. + # The function can also fail from here, which will mean that a + # restart can fail. + # This logic can also be used in start_post, stop_pre and + # stop_post. + fi # Ensure that our dirs are correct checkpath --dir --owner foo:foo --mode 0664 \\ /var/run/foo /var/cache/foo