Bug 32687

Summary: scripts in /usr/local/etc/rc.d not executed in 4.4-STABLE
Product: Base System Reporter: Nicholas Paufler <echofox>
Component: miscAssignee: Peter Pentchev <roam>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description Nicholas Paufler 2001-12-11 05:00:02 UTC
After doing an upgrade from 4.3-STABLE (built May 08 2001) to 4.4-STABLE (built Dec 10 2001) I noticed that local packages being started via scripts in /usr/local/etc/rc.d were not being executed upon reboot.
I'd done a mergemaster after completing the make installworld in which I installed all new files except for rc.conf and rc.firewall.

I eventually traced the problem to /etc/rc
For whatever reason the local package initialization section of that file was failing to function correctly. I edited that file and pasted in the section from a different 4.3-STABLE machine, rebooted and the problem was solved. All local packages (apache, dhcpd, mysql) started properly.

Fix: 

In the /etc/rc for 4.4-STABLE as of December 10th:
Replace the current section:
case ${local_startup} in
[Nn][Oo] | '')
        ;;
*)
        echo -n 'Local package initialization:'
        slist=""
        for dir in ${local_startup}; do
                if [ -d "${dir}" ]; then
                        for script in ${dir}/*.sh; do
                                slist="${slist}${script_name_sep}${script}"
                        done
                fi
        done
        script_save_sep="$IFS"
        IFS="${script_name_sep}"
        for script in ${slist}; do
                if [ -x "${script}" ]; then
                        (set -T
                        trap 'exit 1' 2
                        ${script} start)
                fi
        done
        IFS="${script_save_sep}"
        echo '.'
        ;;
esac

With an earlier version of that section, such as the following taken from a 4.3-STABLE system:

case ${local_startup} in
[Nn][Oo] | '')
        ;;
*)
        echo -n 'Local package initialization:'
        for dir in ${local_startup}; do
                if [ -d "${dir}" ]; then
                        for script in ${dir}/*.sh; do
                                if [ -x "${script}" ]; then
                                        (set -T
                                         trap 'exit 1' 2
                                         ${script} start)
                                fi
                        done
                fi
        done
        echo '.'
        ;;
esac

I'm guessing that there is a typo or some other problem in the local package init section of the current /etc/rc which is causing the problem.
How-To-Repeat: Local packages will not be initialized until that section of /etc/rc is replaced so every time the computer reboots the problem will repeat.
Comment 1 Peter Pentchev 2001-12-11 15:50:55 UTC
On Mon, Dec 10, 2001 at 08:58:06PM -0800, Nicholas Paufler wrote:
> 
> >Number:         32687
> >Category:       misc
> >Synopsis:       scripts in /usr/local/etc/rc.d not executed in 4.4-STABLE
> >Originator:     Nicholas Paufler
> >Release:        FreeBSD 4.4-STABLE #0: Mon Dec 10 18:49:42 MST 2001
> >Organization:
> >Environment:
> FreeBSD www.discordia.ca 4.4-STABLE FreeBSD 4.4-STABLE #0: Mon Dec 10 18:49:42 MST 2001     root@www.discordia.ca:/usr/obj/usr2/src/sys/DISCORDIA  i386
> >Description:
> After doing an upgrade from 4.3-STABLE (built May 08 2001) to 4.4-STABLE (built Dec 10 2001) I noticed that local packages being started via scripts in /usr/local/etc/rc.d were not being executed upon reboot.
> I'd done a mergemaster after completing the make installworld in which I installed all new files except for rc.conf and rc.firewall.

OK, dumb question: does your /etc/defaults/rc.conf have a line like:
script_name_sep=" "	# Change if your startup scripts' names contain spaces

G'luck,
Peter

-- 
What would this sentence be like if it weren't self-referential?
Comment 2 Peter Pentchev 2001-12-11 16:12:23 UTC
Forwarding a message from the submitter to put it on the audit trail..

G'luck,
Peter

-- 
If the meanings of 'true' and 'false' were switched, then this sentence wouldn't be false.

----- Forwarded message from Nicholas Echo|Fox Paufler <echofox@discordia.ca> -----

Date: Tue, 11 Dec 2001 09:04:36 -0700 (MST)
From: "Nicholas \"Echo|Fox\" Paufler" <echofox@discordia.ca>
X-Sender: echofox@kindercampus.ab.ca
To: Peter Pentchev <roam@ringlet.net>
Subject: Re: misc/32687: scripts in /usr/local/etc/rc.d not executed in
 4.4-STABLE
In-Reply-To: <20011211175055.A578@straylight.oblivion.bg>

> 
> OK, dumb question: does your /etc/defaults/rc.conf have a line like:
> script_name_sep=" "	# Change if your startup scripts' names contain spaces
> 
> G'luck,
> Peter
> 

Nope, that it does not. ...
Ahhh.. just looking at the line now. I get what the problem is. since
script_name_sep is undefined, slist is going to be equal to something like
"apache.shmysql.shdhcpd.sh" and thus isn't going to exceute them because
obviously such a file does not exist.

So I take it my problem is an old and crufty version of
/etc/defaults/rc.conf, then? Hmm. I would have thought mergemaster would
have installed a current one, especially in a case where stuff is
dependent on new additions to it.

I trust that copying over /usr/src/etc/defaults/rc.conf should take care
of my problems?

Thanks for your help.

Nicholas Paufler



----- End forwarded message -----
Comment 3 Peter Pentchev freebsd_committer freebsd_triage 2001-12-11 16:27:40 UTC
State Changed
From-To: open->closed

It turns out that the mergemaster run had for some reason 
not updated /etc/defaults/rc.conf.
Comment 4 Sheldon Hearn 2001-12-11 16:28:35 UTC
On Tue, 11 Dec 2001 08:20:01 PST, Peter Pentchev wrote:

>  Ahhh.. just looking at the line now. I get what the problem is. since
>  script_name_sep is undefined, slist is going to be equal to something like
>  "apache.shmysql.shdhcpd.sh" and thus isn't going to exceute them because
>  obviously such a file does not exist.

Peter, do you think it's worth building a default value for script_name_sep
into rc itself so this doesn't bite folks in the 4.5-RELEASE upgrade?

I accept that you'd have to try hard to be bitten, but this little bit
of ugliness may save us a few PRs?

Ciao,
Sheldon.
Comment 5 Peter Pentchev freebsd_committer freebsd_triage 2001-12-11 16:37:51 UTC
State Changed
From-To: closed->analyzed

Actually, Sheldon suggested a helpful workaround.
Comment 6 Peter Pentchev 2001-12-11 16:51:49 UTC
On Tue, Dec 11, 2001 at 08:30:01AM -0800, Sheldon Hearn wrote:
> The following reply was made to PR misc/32687; it has been noted by GNATS.
> 
>  On Tue, 11 Dec 2001 08:20:01 PST, Peter Pentchev wrote:
>  
>  >  Ahhh.. just looking at the line now. I get what the problem is. since
>  >  script_name_sep is undefined, slist is going to be equal to something like
>  >  "apache.shmysql.shdhcpd.sh" and thus isn't going to exceute them because
>  >  obviously such a file does not exist.
>  
>  Peter, do you think it's worth building a default value for script_name_sep
>  into rc itself so this doesn't bite folks in the 4.5-RELEASE upgrade?
>  
>  I accept that you'd have to try hard to be bitten, but this little bit
>  of ugliness may save us a few PRs?

This makes sense.  How about the attached patch?
The warning message clutters the output, though; it almost certainly
overflows to the next line on the screen, not to mention overflowing
the 80-character source line..  I am thinking of shortening it somehow,
maybe you or somebody else could suggest another wording?

G'luck,
Peter

-- 
I am the meaning of this sentence.

Index: src/etc/rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.287
diff -u -r1.287 rc
--- src/etc/rc	11 Dec 2001 08:21:45 -0000	1.287
+++ src/etc/rc	11 Dec 2001 16:43:24 -0000
@@ -813,6 +813,10 @@
 *)
 	echo -n 'Local package initialization:'
 	slist=""
+	if [ -z "${script_name_sep}" ]; then
+		echo -n ' Empty script_name_sep, setting a default value of " "..'
+		script_name_sep=" "
+	fi
 	for dir in ${local_startup}; do
 		if [ -d "${dir}" ]; then
 			for script in ${dir}/*.sh; do
Index: src/etc/rc.shutdown
===================================================================
RCS file: /home/ncvs/src/etc/rc.shutdown,v
retrieving revision 1.20
diff -u -r1.20 rc.shutdown
--- src/etc/rc.shutdown	24 Nov 2001 16:12:03 -0000	1.20
+++ src/etc/rc.shutdown	11 Dec 2001 16:42:36 -0000
@@ -103,6 +103,10 @@
 	;;
 *)
 	slist=""
+	if [ -z "${script_name_sep}" ]; then
+		echo -n ' Empty script_name_sep, setting a default value of " "..'
+		script_name_sep=" "
+	fi
 	for dir in ${local_startup}; do
 		if [ -d "${dir}" ]; then
 			for script in ${dir}/*.sh; do
Comment 7 Sheldon Hearn 2001-12-11 17:00:07 UTC
On Tue, 11 Dec 2001 18:51:49 +0200, Peter Pentchev wrote:

> This makes sense.  How about the attached patch?
> The warning message clutters the output, though; it almost certainly
> overflows to the next line on the screen, not to mention overflowing
> the 80-character source line..  I am thinking of shortening it somehow,
> maybe you or somebody else could suggest another wording?

I'd suggest removing the warning altogether.  Anyone who's managed to
mangle things in a 4.5-RELEASE upgrade to the point where they see this
message is unlikely to know how to make it go away.

I like the rest of the patch. :-)

Ciao,
Sheldon.
Comment 8 Peter Pentchev 2001-12-11 17:05:35 UTC
On Tue, Dec 11, 2001 at 07:00:07PM +0200, Sheldon Hearn wrote:
> 
> 
> On Tue, 11 Dec 2001 18:51:49 +0200, Peter Pentchev wrote:
> 
> > This makes sense.  How about the attached patch?
> > The warning message clutters the output, though; it almost certainly
> > overflows to the next line on the screen, not to mention overflowing
> > the 80-character source line..  I am thinking of shortening it somehow,
> > maybe you or somebody else could suggest another wording?
> 
> I'd suggest removing the warning altogether.  Anyone who's managed to
> mangle things in a 4.5-RELEASE upgrade to the point where they see this
> message is unlikely to know how to make it go away.
> 
> I like the rest of the patch. :-)

Okay; the warning was actually an afterthought :)

If nobody objects, I will commit the attached patch tomorrow morning
(my morning, about twelve hours from now :)

G'luck,
Peter

-- 
If the meanings of 'true' and 'false' were switched, then this sentence wouldn't be false.

Index: src/etc/rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.287
diff -u -r1.287 rc
--- src/etc/rc	11 Dec 2001 08:21:45 -0000	1.287
+++ src/etc/rc	11 Dec 2001 17:04:51 -0000
@@ -813,6 +813,9 @@
 *)
 	echo -n 'Local package initialization:'
 	slist=""
+	if [ -z "${script_name_sep}" ]; then
+		script_name_sep=" "
+	fi
 	for dir in ${local_startup}; do
 		if [ -d "${dir}" ]; then
 			for script in ${dir}/*.sh; do
Index: src/etc/rc.shutdown
===================================================================
RCS file: /home/ncvs/src/etc/rc.shutdown,v
retrieving revision 1.20
diff -u -r1.20 rc.shutdown
--- src/etc/rc.shutdown	24 Nov 2001 16:12:03 -0000	1.20
+++ src/etc/rc.shutdown	11 Dec 2001 17:04:52 -0000
@@ -103,6 +103,9 @@
 	;;
 *)
 	slist=""
+	if [ -z "${script_name_sep}" ]; then
+		script_name_sep=" "
+	fi
 	for dir in ${local_startup}; do
 		if [ -d "${dir}" ]; then
 			for script in ${dir}/*.sh; do
Comment 9 Sheldon Hearn freebsd_committer freebsd_triage 2001-12-12 08:40:24 UTC
Responsible Changed
From-To: freebsd-bugs->roam

Peter's gonna deal with this one.
Comment 10 Peter Pentchev freebsd_committer freebsd_triage 2001-12-12 10:16:52 UTC
State Changed
From-To: analyzed->suspended

I committed the fix to -current, will MFC it in a week.
Comment 11 Peter Pentchev freebsd_committer freebsd_triage 2001-12-20 06:31:45 UTC
State Changed
From-To: suspended->closed

The initialization of script_name_sep with a sane value was MFC'd 
into -stable yesterday. 
Thank you for the problem report!