starting services?

Karol Kwiatkowski freebsd at orchid.homeunix.org
Mon Nov 21 15:24:09 GMT 2005


Michael Beattie wrote:
> On 11/21/05, Halldor R. Haflidason <titan at thoron.org> wrote:
>> On Monday, 21 November 2005 at 15:11:35 +0100, martinko wrote:
>>> On Mon, 21 Nov 2005 10:17:01 +0800, Foo Ji-Haw wrote
>>>>> i wonder why i cannot start for instance ssh with
>>>>> /etc/rc.d/sshd start
>>>>> but i always have to use
>>>>> /etc/rc.d/sshd forcestart
>>>>> and similarly for stop, status, etc.
>>>>>
>>>>> any ideas pls ??
>>>> You have to add a line in /etc/rc.conf. I think it is
>>>> samba_enable="YES".
>>>
>>> well, if you add sshd_enable="YES", the service (always) starts on boot.
>>>
>>> i just want to start it manually and i wonder why it doesn't listen to "start"
>>> argument but only "forcestart" and similarly for other commands i've got to
>>> use "force".
>>>
>>> anyone knows why pls ??
>>>
>>> martin
>> Because when the system boots up it sends the 'start' argument to all the
>> scripts in the rc.d directories, those scripts then check wether they
>> should start or not. Force start simply overrides that check.
>>
>> Halldor
> 
> Then something's broken, no?  If the service isnt running and you send
> it a "start" and it doesnt start, then that's bad.  You shouldnt need
> to override some checks, it should do what it's commanded to do.

If you're talking about implementation no, it's not. In order to start
a service with "start" argument it needs to be "enabled" in
/etc/rc.conf. It's nicely documented in various places like man 8 rc
or /etc/rc.subr.

What OP is looking for is 'onestart' and 'onestop' parameters. I was
looking for a solution to the same issue some days ago and found that
in /etc/rc.subr:

#       If argument has a given prefix, then change the operation as
follows:
#               Prefix  Operation
#               ------  ---------
#               fast    Skip the pid check, and set rc_fast=yes
#               force   Set ${rcvar} to YES, and set rc_force=yes
#               one     Set ${rcvar} to YES

Basically "/etc/rc.d/sshd onestart" will let you run sshd service
without enabling it in rc.conf (which also means it'll start at boot
time) yet it checks if sshd is not running already.

Hope that helps,

Karol

-- 
Karol Kwiatkowski  <freebsd at orchid dot homeunix dot org>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20051121/50e20aea/signature.bin


More information about the freebsd-questions mailing list