Difference between revisions of "Initscripts/Writing rc.d scripts"

From ArchWiki
Jump to: navigation, search
m (no paren)
(gr; formality; bogus filenames)
Line 9: Line 9:
 
{{Article summary end}}
 
{{Article summary end}}
  
As part of Arch's 'BSD-style' init, rc.d scripts are used to control the starting,stopping and restarting of [[Daemon|daemons]]. This guide will help to create your own rc.d scripts.
+
As part of Arch's 'BSD-style' init, rc.d scripts are used to control the starting, stopping and restarting of [[Daemon|daemons]]. This guide will help in writing these scripts.
  
 
==Guideline==
 
==Guideline==
 
*Source {{Filename|/etc/rc.conf}}, {{Filename|/etc/rc.d/functions}}, and optionally {{Filename|/etc/conf.d/DAEMON_NAME}}.
 
*Source {{Filename|/etc/rc.conf}}, {{Filename|/etc/rc.d/functions}}, and optionally {{Filename|/etc/conf.d/DAEMON_NAME}}.
 
*Arguments and other daemon options should be placed in {{Filename|/etc/conf.d/DAEMON_NAME}}. This is done to separate configuration from logic and to keep a consistent style among daemon scripts.
 
*Arguments and other daemon options should be placed in {{Filename|/etc/conf.d/DAEMON_NAME}}. This is done to separate configuration from logic and to keep a consistent style among daemon scripts.
*Use functions in {{Filename|/etc/rc.d/functions}}.
+
*Use functions in {{Filename|/etc/rc.d/functions}} instead of duplicating their functionality.
*Include at least start, stop and restart.
+
*Include at least start, stop and restart as arguments to the script.
  
 
==Example==
 
==Example==
The following is an example for ''crond''. Look in {{Filename|/etc/rc.d}} for a greater variety.
+
The following is an example for ''crond''. Look in {{Filename|/etc/rc.d}} for greater variety.
  
 
The configuration file:
 
The configuration file:
{{File|name=/etc/conf.d/tftpd|content=<nowiki>ARGS="-S -l info"</nowiki>}}
+
{{File|name=/etc/conf.d/crond|content=<nowiki>ARGS="-S -l info"</nowiki>}}
  
 
The actual script:
 
The actual script:
{{File|name=/etc/rc.d/tftpd|content=<nowiki>
+
{{File|name=/etc/rc.d/crond|content=<nowiki>
 
#!/bin/bash
 
#!/bin/bash
  

Revision as of 03:44, 14 January 2011

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

As part of Arch's 'BSD-style' init, rc.d scripts are used to control the starting, stopping and restarting of daemons. This guide will help in writing these scripts.

Guideline

Example

The following is an example for crond. Look in Template:Filename for greater variety.

The configuration file: Template:File

The actual script: Template:File