LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Add an init script? (https://www.linuxquestions.org/questions/linux-newbie-8/add-an-init-script-554692/)

rogueeve 05-17-2007 02:21 PM

Add an init script?
 
Here's an easy one: what's the right way to add an init script under /etc/rc.d/init.d (Fedora)? I assumed Fedora just enumerated and ran every file in that directory at bootup but it does not appear to work that way. I got my scripts to run by hijacking the bluetooth one to call them but obviously this isn't the Right Way.

marozsas 05-17-2007 02:53 PM

If the script is in /etc/init.d and it's header follows a LSB convention for this, it can be set to start at boot time at the pre-defined run-levels, by running "chkconfig name-of-init-script on" (or off). Check chkconfig man page for other options.

chkconfig will read the following header of init script to figure out what run-levels it should run and what are the dependencies for other services. For example, the festival init script has the following header:
Code:

### BEGIN INIT INFO
# Provides:          festival
# Required-Start:    $syslog $remote_fs
# Should-Start:      $time
# Required-Stop:    $syslog $remote_fs
# Should-Stop:      $time
# Default-Start:    3 5
# Default-Stop:      0 1 2 6
# Short-Description: festival daemon providing full text-to-speech system
# Description:      Start festival to allow applications to access a
#      text-to-speech system with various APIs, as well as an environment
#      for development and research of speech synthesis techniques. It is
#      written in C++ and has a Scheme-based command interpreter for
#      general control.
### END INIT INFO

chkconfig will create or remove the right links at /etc/init.d/rc[0123456S].d as needed.


All times are GMT -5. The time now is 04:26 PM.