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

From ArchWiki
Jump to: navigation, search
(Example)
(Guideline: added description for some functions)
Line 16: Line 16:
 
*Use functions in {{Filename|/etc/rc.d/functions}} instead of duplicating their functionality.
 
*Use functions in {{Filename|/etc/rc.d/functions}} instead of duplicating their functionality.
 
*Include at least start, stop and restart as arguments to the script.
 
*Include at least start, stop and restart as arguments to the script.
 +
*There are some functions provided by {{Filename|/etc/rc.d/functions}}:
 +
**stat_busy "<message>": set status ''busy'' for printed message (e.g. <nowiki>Starting daemon  [BUSY]</nowiki>)
 +
**stat_done: set status ''done'' (e.g. <nowiki>Starting daemon  [DONE]</nowiki>)
 +
**stat_fail: set status ''failed'' (e.g. <nowiki>Starting daemon  [FAILED]</nowiki>)
 +
**get_pid <program>: get PID of the program
 +
**ck_pidfile <PID-file> <program>: check whether PID-file is still valid for the program (e.g. <nowiki>ck_pidfile /var/run/daemon.pid daemon || rm -f /var/run/daemon.pid</nowiki>)
 +
**[add|rm]_daemon <program>: add/remove program to running daemons (stored in {{Filename|/run/daemons/}})
  
 
==Example==
 
==Example==

Revision as of 23:13, 30 July 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Summary help replacing me
Writing rc.d daemon scripts.
Related
Arch Boot Process
Daemon
rc.conf

As part of Arch's 'BSD-style' init, rc.d scripts are used to control the starting, stopping and restarting of daemons.

Guideline

  • Source Template:Filename, Template:Filename, and optionally Template:Filename.
  • Arguments and other daemon options should be placed in Template:Filename. This is done to separate configuration from logic and to keep a consistent style among daemon scripts.
  • Use functions in Template:Filename instead of duplicating their functionality.
  • Include at least start, stop and restart as arguments to the script.
  • There are some functions provided by Template:Filename:
    • stat_busy "<message>": set status busy for printed message (e.g. Starting daemon [BUSY])
    • stat_done: set status done (e.g. Starting daemon [DONE])
    • stat_fail: set status failed (e.g. Starting daemon [FAILED])
    • get_pid <program>: get PID of the program
    • ck_pidfile <PID-file> <program>: check whether PID-file is still valid for the program (e.g. ck_pidfile /var/run/daemon.pid daemon || rm -f /var/run/daemon.pid)
    • [add|rm]_daemon <program>: add/remove program to running daemons (stored in Template:Filename)

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