Starting a service on boot

Jean-Philippe Daigle jean.daigle at SolaceSystems.com
Mon Mar 5 15:54:15 UTC 2007


> -----Original Message-----
> From: Jerry McAllister [mailto:jerrymc at msu.edu]
> Sent: Monday, March 05, 2007 10:44 AM
> To: Jean-Philippe Daigle
> Cc: freebsd-questions at freebsd.org
> Subject: Re: Starting a service on boot
> 
> On Mon, Mar 05, 2007 at 09:37:54AM -0500, Jean-Philippe Daigle wrote:
> 
> > Hello,
> >
> > I'm attempting to add a new program to the list of services starting
at
> > boot time on FreeBSD 6.1. Unfortunately, although running the script
> > directly as root starts it up just fine, it's not starting at boot
time.
> > I've found documentation that says there are two basic steps to
follow:
> >
> > 1) Create a script named, say, 'foo' starting the program, place it
in
> > /etc/rc.d/, and make sure it satisfies a few minimal requirements
(see
> > script below).
> >
> > 2) Edit rc.conf to add "foo_enable=YES" so the init system knows to
> > start the new program.
> >
> > I've done (2), and here's the script for (1) (anything between <> is
me
> > redacting a username, it's obviously not that way in the script):
> 
> A couple of comments before attemting to look at the script:
> 
> First, it should go in to '/usr/local/etc/rc.d', not just plain
/etc/rc.d
>   The /etc/rc.d location is reserved for system stuff and may be nuked
>   (overwritten) in an upgrade.  /usr/local/etc/rc.d is reserved for
user
>   installed third party and locally written scripts and will generally
be
>   preserved over upgrades.
> Second, it needs to have execute permission set.
> Third, the name used to have to end in '.sh'.   I don't know if that
>   is still true.   Mine all do.
> Finally, the only value of putting something like 'foo_enable="YES"'
in
>   your rc.conf is if the script itself checks for the value on
>   a 'foo_enable' environmental variable.  The system doesn't care
>   about it.   I don't see this in your script.
> Also, if you want messages to show in the logs, then you will have to
>   put writing them in to your script.
> 
> Once those things are dealt with, then see what that script does.
> 
> ////jerry
> 

Jerry M. and Roland S.,

	Many thanks for your comments, that was it! Looks like renaming
it to "cruisecontrol.sh" and moving it to /usr/local instead of the
reserved /etc/rc.d got the script to run on boot.

I still had a problem with which environment variables were set in the
shell that starts up cruisecontrol, but that was rapidly fixed.
Everything is working now.

> Finally, the only value of putting something like 'foo_enable="YES"'
in
>   your rc.conf is if the script itself checks for the value on
>   a 'foo_enable' environmental variable.  The system doesn't care
>   about it.   I don't see this in your script.

Oh, that's interesting. I thought that would control the script's
startup. In any case, I'll add a check for it if it's ever needed.

Thanks!
Jean-Philippe Daigle
 


More information about the freebsd-questions mailing list