ports/100350: www/apache20 profiles not working at system startup/shutdown time due to unexpected $0 value
mandrews at bit0.com
Sat Jul 15 18:50:14 UTC 2006
>Synopsis: www/apache20 profiles not working at system startup/shutdown time due to unexpected $0 value
>Arrival-Date: Sat Jul 15 18:50:13 GMT 2006
>Originator: Mike Andrews
>Release: FreeBSD 6.1-STABLE amd64
System: FreeBSD mindcrime.bit0.com 6.1-STABLE FreeBSD 6.1-STABLE #1: Fri Jul 14 18:53:37 EDT 2006 mandrews at mindcrime.bit0.com:/usr/obj/usr/src/sys/MINDCRIME amd64
Also happens on 6.1-RELEASE-p2 i386 GENERIC or SMP
When using the latest apache20 port (from July 14 2006 portsnap) and the profiles
feature to run multiple httpd's on one system (or even just a single profile),
such as the following in /etc/rc.conf:
Manually using "/usr/local/etc/rc.d/apache2.sh start 0DEV" (or stop or reload
or restart) works fine.
Manually using "/usr/local/etc/rc.d/apache2.sh start" (or stop or reload but
NOT restart) works fine. restart not working may be related to ports/86402
but that's not that this PR is about :)
At system boot time though, it fails to start Apache with the following error:
===> apache2 profile: 0DEV
/usr/local/etc/rc.d/apache2.sh: /etc/rc: Permission denied
On line 73 of /usr/local/etc/rc.d/apache2.sh is a line "$0 $1 $profile" that's
used to re-run apache2.sh for each individual profile. If I put $0 into the
"echo" line above it, it says $0 is "/etc/rc.d" so it fails when it tries to
re-run the wrong script. The upshot is I have to manually restart Apache after
At system shutdown $0 gets mangled into "/etc/rc.shutdown" instead of
"/usr/local/etc/rc.d/apache2.sh" the same way.
If I create a simple /usr/local/etc/rc.d/test.sh script containing just
echo Hello, I seem to be $0
then it prints /usr/local/etc/rc.d/test.sh as expected. Putting that as
the first line in /usr/local/etc/rc.d/apache.2.sh prints /etc/rc at startup,
/etc/rc.shutdown at shutdown and /usr/local/etc/rc.d/apache2.sh when run
manually. 'm not sure why that one is different. It does run earlier than
some of the others.
With no profiles enabled everything works fine because it never needs to
reference $0 in that case.
Install www/apache20 on a system (or jail), add the above variables to
/etc/rc.conf, and restart the system (or jail); if a jail then check
/var/log/console.log for the above error messages.
Using $_file instead of $0 works for system boot but breaks the manual case.
Perhaps using $_file if it exists and $0 when it doesn't?
There is the possibility that I've done something stupid to my /etc/rc.conf,
(like not using the apache20 profile variables correctly) or that I have another
port whose rc.d script is trashing $0 somehow, or that I just plain don't understand
the rc system. :)
More information about the freebsd-ports-bugs