Rc script

From LQWiki
Jump to: navigation, search

RC-Scripts are scripts that define the basic functions of each service, as well as each service's dependencies for start-up. The RC-Scripts often live in /etc/init.d/, but on some systems may live in /etc/rc.d.

Here is the general layout of an RC-Script:

#!/sbin/runscript
 
depend() {
    need bar
}
 
start() {
    ebegin "Starting foo"
    /sbin/foo
    eend $? "Failed to start foo"
}
 
stop() {
    ebegin "Stopping foo"
    kill $(cat /var/run/foo.pid)
    eend $? "Failed to stop foo"
}

See also

External links