Startup script not executing after reboot on Solaris

solaris

I have a command to start Apache in /etc/rc3.d that does not execute when the server reboots. The script is named S75Apache2. Someone has speculated that this is because the link has a capital "A" in the name and it might work if renamed to S75apache2.

Can anyone confirm? I've searched for documentation but cannot find an answer. I can't really test this without rebooting the server again (which I'd rather not do).

Best Answer

Solaris init scripts are a pain. The capital-A doesn't matter, there's a script in /etc/rc.d that finds every file in /etc/rc3.d that starts with 'S' and runs them in numerical order.

That leaves you with Starting From The Basics:

  1. Is /etc/rc3.d/S75Apache2 set executable?

  2. Does that script have a '#!' line? Is the line correct (no non-printing bytes, etc)?

  3. If it's a bash or ksh script run it as ksh -n /etc/rc3.d/S75Apache2 start. That will tell you if it has syntax errors.

  4. If you can run that script as root, try it: /etc/rc3.d/S75Apache2 start and /etc/rc3.d/S75Apache2 stop Check carefully to see if it startshttpd and stops httpd. At the very least run the script with 'start' and 'stop' arguments yourself. Use set -x to see what the script does at run time. Check to see if what it does matches what you believe it does.

  5. Read /etc/rc3.d/S75Apache2 carefully. PATH is sparsely populated at boot, and your script may not know where some executables are at boot time, but might when run after booting. Try not to assume too much - files might not exist that you think exist, things like that.

  6. Ensure that a KnnApache2 script doesn't exist in /etc/rc3.d. I beliee that the Solaris init will run (for example) K76Apache2 stop when it transitions from run level 3 to run level 5.

  7. Ensure that the script changes user ID appropriately. This probably isn't important for Apache, given that your script probably just calls apachectl start with some prologue commands, but if you run http directly, make sure that the resulting httpd process has the correct user ID. Use sudo or something in the script to get it right.

Related Question