Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Sep 2014 22:08:16 -0400
From:      Eric van Gyzen <eric@vangyzen.net>
To:        Alfred Perlstein <alfred@freebsd.org>
Cc:        arch@freebsd.org, Ian Lepore <ian@FreeBSD.org>
Subject:   Re: Trouble with freebsd rc system.
Message-ID:  <9B16D77C-0FD9-4A7B-AA13-009D0FC3A511@vangyzen.net>
In-Reply-To: <54161C50.3000507@freebsd.org>
References:  <54161633.60207@freebsd.org> <1410734453.66615.2.camel@revolution.hippie.lan> <54161C50.3000507@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Sep 14, 2014, at 6:53 PM, Alfred Perlstein <alfred@freebsd.org> wrote:

> 
> On 9/14/14, 3:40 PM, Ian Lepore wrote:
>> On Sun, 2014-09-14 at 15:26 -0700, Alfred Perlstein wrote:
>>> Hey folks,
>>> 
>>> We are building an appliance based on FreeBSD.
>>> 
>>> One of the issues we have is that during development we need to know
>>> which rc script we are in during boot so that if something is hanging or
>>> otherwise misbehaving we know which script it is.
>>> 
>>> I am contemplating this hack to /etc/rc.subr's run_rc_command() method:
>>> 
>>>     run_rc_command()
>>>     {
>>>          _return=0
>>>          rc_arg=$1
>>>          if [ -z "$name" ]; then
>>>              err 3 'run_rc_command: $name is not set.'
>>>          fi
>>> 
>>>          # Don't repeat the first argument when passing additional command-
>>>          # line arguments to the command subroutines.
>>>          #
>>>          shift 1
>>>          rc_extra_args="$*"
>>> 
>>>          echo "===> $name $rc_arg"
>>> 
>>> 
>>> As you can see I've added the call to echo so we know where we are.
>>> 
>>> This is somewhat suboptimal because we really only want that output
>>> during startup.
>>> 
>>> So a few questions:
>>> 
>>> 1. Is there a way to know we are booting when inside of
>>> /etc/rc.subr:run_rc_command() ?
>>> 2. Is there a magic thing I'm missing that does what I want (output
>>> which /etc/rc.d/ script I am about to run)?
>>> 3. How would I make a knob to turn off the "echo" so that I can
>>> contribute this back to FreeBSD without getting into a bikeshed on
>>> bootup messages.
>>> 
>>> Kindly please advise.
>>> 
>>> -Alfred
>> A bit further down in run_rc_command, in the start) case, is:
>> 
>>              check_startmsgs && echo "Starting ${name}."
>> 
>> and that output is controlled with rc_startmsgs=yes, which is the
>> default.
>> 
>> -- Ian
>> 
>> 
>> 
> I see that, however I've often been hung up in a rc script and that message is not displayed... let me check, maybe we have dumb defaults somehow.

run_rc_script() sets up a signal hander for SIGINFO, so you can type Ctrl-T to see which script is currently running.

Eric


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9B16D77C-0FD9-4A7B-AA13-009D0FC3A511>