Re: Starting a service on boot

2007-03-05 Thread Robert Huff
Derek Ragona writes:


>  In most cases you want the service to write the PID to a file in
>  /var/log so only one instance is started.

Ins't the canonical location for this "/var/run"?


Robert Huff
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Starting a service on boot

2007-03-05 Thread Derek Ragona

rc scripts should accept a few arguments:
start
stop
restart

You can usually find one in /usr/local/etc/rc.d to copy from.

In most cases you want the service to write the PID to a file in /var/log 
so only one instance is started.  Also be sure you use full pathnames in 
your scripts, don't assume an environment exists.


-Derek


At 08:37 AM 3/5/2007, 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):

(/etc/rc.d)$ cat cc
#!/bin/sh
#
# PROVIDE: cc
# REQUIRE: DAEMON

. /etc/rc.subr

name="cc"
rcvar=`set_rcvar`
command="/home//cruisecontrol.sh"
command_args="&"
cc_user=""

load_rc_config $name
run_rc_command "$1"


I can also check if it's enabled:
(/etc/rc.d)$ ./cc rcvar
# cc
$cc_enable=YES

I haven't found anything interesting in the system logs from the last
boot - any ideas why it's not starting up?

Thanks
-Jean-Philippe Daigle

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


RE: Starting a service on boot

2007-03-05 Thread Jean-Philippe Daigle
> -Original Message-
> From: Jerry McAllister [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 05, 2007 10:44 AM
> To: Jean-Philippe Daigle
> Cc: freebsd-questions@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
 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Starting a service on boot

2007-03-05 Thread Jerry McAllister
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


> 
> (/etc/rc.d)$ cat cc
> #!/bin/sh
> #
> # PROVIDE: cc
> # REQUIRE: DAEMON
> 
> . /etc/rc.subr
> 
> name="cc"
> rcvar=`set_rcvar`
> command="/home//cruisecontrol.sh"
> command_args="&"
> cc_user=""
> 
> load_rc_config $name
> run_rc_command "$1"
> 
> 
> I can also check if it's enabled:
> (/etc/rc.d)$ ./cc rcvar 
> # cc
> $cc_enable=YES
> 
> I haven't found anything interesting in the system logs from the last
> boot - any ideas why it's not starting up?
> 
> Thanks
> -Jean-Philippe Daigle
> 
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"
> 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Starting a service on boot

2007-03-05 Thread Roland Smith
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).

The proper place is /usr/local/etc/rc.d.
 
> 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):
> 
> (/etc/rc.d)$ cat cc

Better to name the script and the service "cruisecontrol" instead of
using the name of the system C compiler. It avoids confusion.

> #!/bin/sh
> #
> # PROVIDE: cc
> # REQUIRE: DAEMON

I'd make that "REQUIRE: mountlate" if /home is not on the / partition.
 
> . /etc/rc.subr
> 
> name="cc"
> rcvar=`set_rcvar`
> command="/home//cruisecontrol.sh"
> command_args="&"
> cc_user=""

Does /home//cruisecontrol.sh needs cc_user?

This environment variable is only available in this subshell. It is not
exported, so /home//cruisecontrol.sh doesn't see it.

Roland
-- 
R.F.Smith   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)


pgpUgw27AtY8s.pgp
Description: PGP signature


RE: Starting a service on boot

2007-03-05 Thread Jean-Philippe Daigle

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:owner-freebsd-
> [EMAIL PROTECTED] On Behalf Of Chris Slothouber
> Sent: Monday, March 05, 2007 10:05 AM
> To: FreeBSD-questions@FreeBSD.org
> Subject: Re: Starting a service on boot
> 
> Perhaps you could put a debug point in the script to ensure it is
being
> started (e.g. touch a file or echo something to the terminal), and if
it
> is indeed being run by rc, move the point until you find out where
it's
> breaking?

Thanks for the suggestion! I did, and it really looks like the script
never gets started.

Permissions:
(/etc/rc.d)$ ls -l cc.sh 
-rwxr-xr-x  1 root  wheel  246 Mar  5 10:11 cc.sh

Script contents:
(/etc/rc.d)$ cat cc.sh 
#!/bin/sh
#
# PROVIDE: cc
# REQUIRE: DAEMON

. /etc/rc.subr

touch /tmp/quuux

name="cc"
rcvar=`set_rcvar`
command="/home//cruisecontrol/cruisecontrol.sh"
command_args="&"
cc_user=""

load_rc_config $name
run_rc_command "$1"

Of course, the file /tmp/quuux never gets created, so the script
isn't running.

-JP

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Starting a service on boot

2007-03-05 Thread Chris Slothouber
Perhaps you could put a debug point in the script to ensure it is being 
started (e.g. touch a file or echo something to the terminal), and if it 
is indeed being run by rc, move the point until you find out where it's 
breaking?


Jean-Philippe Daigle wrote:

-Original Message-
From: [EMAIL PROTECTED] [mailto:owner-freebsd-
[EMAIL PROTECTED] On Behalf Of Chris Slothouber
Sent: Monday, March 05, 2007 9:53 AM
To: FreeBSD-questions@FreeBSD.org
Subject: Re: Starting a service on boot

I think you need to call it cc.sh
And make sure it's +x



Thanks, the script is definitely executable. I tried renaming it to
"cc.sh" and rebooting, to no effect. Still nothing interesting in the
logs from this boot...

Jean-Philippe Daigle



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


RE: Starting a service on boot

2007-03-05 Thread Jean-Philippe Daigle
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:owner-freebsd-
> [EMAIL PROTECTED] On Behalf Of Chris Slothouber
> Sent: Monday, March 05, 2007 9:53 AM
> To: FreeBSD-questions@FreeBSD.org
> Subject: Re: Starting a service on boot
> 
> I think you need to call it cc.sh
> And make sure it's +x
> 

Thanks, the script is definitely executable. I tried renaming it to
"cc.sh" and rebooting, to no effect. Still nothing interesting in the
logs from this boot...

Jean-Philippe Daigle

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Starting a service on boot

2007-03-05 Thread Chris Slothouber

I think you need to call it cc.sh
And make sure it's +x

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):

(/etc/rc.d)$ cat cc
#!/bin/sh
#
# PROVIDE: cc
# REQUIRE: DAEMON

. /etc/rc.subr

name="cc"
rcvar=`set_rcvar`
command="/home//cruisecontrol.sh"
command_args="&"
cc_user=""

load_rc_config $name
run_rc_command "$1"


I can also check if it's enabled:
(/etc/rc.d)$ ./cc rcvar 
# cc

$cc_enable=YES

I haven't found anything interesting in the system logs from the last
boot - any ideas why it's not starting up?

Thanks
-Jean-Philippe Daigle

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"