[NTLUG:Discuss] problems getting some services to start at boot

krannen@gte.net krannen at gte.net
Fri Nov 30 22:32:13 CST 2001


Raymond Norton wrote:

> I am trying to get mrtg and apache to start automatically. I have been
> through the docs, and feel I have done things right, but obviously something
> is wrong.
> 
> mrtg:
> 
> I created a script  called mrtg that launches 17 different configs. It is
> located in /ect/rc.d/init.d . I also created a symbolic link to the mrtg
> script in /etc/rc3.d named S65mrtg.
> 
> It is my understanding this should launch mrtg at boot, but it doesn't. If I
> do a "perl S65mrtg" it fires of.


Whoops!  init scripts are shell scripts, not perl scripts.

Take one of the smaller scripts in the dir, e.g. sshd.  Use that as a 
template, as in:
	cp sshd mrtg
Then rip out the sshd specific things, and fill in yours.  Or use this as a 
template:

----------------------cut--------------------
#!/bin/sh

# Source function library.
. /etc/rc.d/init.d/functions

RETVAL=0

# See how we were called.
case "$1" in
   start)
         # Start daemons.
         echo -n "Starting mrtg: "
         ...do start command...
         RETVAL=$?
         echo
         ;;
   stop)
         # Stop daemons.
         echo -n "Shutting down mrtg: "
         killproc ...program_name...
         RETVAL=$?
         echo
         ;;
   *)
         echo "Usage: mrtg {start|stop}"
         exit 1
esac

exit $RETVAL
-------------------cut-----------------

Fill in the stuff like ...stuff...
There's no other "magic".  If you need to start multiple daemons in the same 
script, just duplicate the "echo/process/RETVAL/echo" lines over and over for 
each one.  Same sort of thing for the stop action.

Also, be sure to put an "&" at the end of your start command if the process 
does not naturally go into background on its own.  Some processes do, some 
you; trial and error is one way to find out (or read the man page).


> 
> I also have about the same problem with apache.
> 
> Any advice would be appreciated.
> 
> This is running on RedHat 7.1 in case that matters.


It shouldn't matter, but like I said, use one of the other scripts as a 
template.  Also, when you can't figure out what's going on, you can test it like:
	sh -x /etc/rc.d/init.d/mrtg

and it will show you what it does as it's doing it, which is very helpful to

see what get's expanded when, catch typos, etc.


HTH,
Kevin







More information about the Discuss mailing list